मैंने एक वेबपृष्ठ लिखा जहां उपयोगकर्ता डेटाबेस पर संग्रहीत लॉग प्रविष्टि दर्ज कर सकता है और फिर ajax
का उपयोग करके पृष्ठ पर पुनर्प्राप्त और मुद्रित किया जा सकता है। मैं अभी भी ajax
पर काफी नया हूं और सोच रहा था कि कोई मुझे बता सकता है कि return false;
मेरे कोड के अंत में क्या करता है? और यह भी जरूरी है?"झूठी वापसी" क्या करता है; कर?
यदि मैं return false
के बाद दूसरा AJAX कोड डालता हूं तो कोड काम नहीं करता है! क्या आप कृपया मुझे समझा सकते हैं क्यों?
//handles submitting the form without reloading page
$('#FormSubmit').submit(function(e) {
//stores the input of today's data
var log_entry = $("#LogEntry").val();
// prevent the form from submitting normally
e.preventDefault();
$.ajax({
type: 'POST',
url: 'behind_curtains.php',
data: {
logentry: log_entry
},
success: function() {
alert(log_entry);
//clears textbox after submission
$('#LogEntry').val("");
//presents successs text and then fades it out
$("#entered-log-success").html("Your Entry has been entered.");
$("#entered-log-success").show().fadeOut(3000);
}
});
//prints new log entries on page upon submittion
$.ajax({
type: 'POST',
url: '/wp-content/themes/childOfFanwood/traininglog_behind_curtains.php',
data: {
log_entries_loop: "true"
},
success: function(data) {
alert(data);
$("#log-entry-container").html("");
$("#log-entry-container").html(data);
}
});
return false;
});
डिफ़ॉल्ट फ़ॉर्म सबमिट करने से रोकता है –
@Dagon। इतना ही नहीं। वास्तविक प्रश्न का उत्तर देने के लिए – gdoron