Ho scritto una pagina Web in cui un utente può immettere una voce di registro memorizzata in un database e quindi recuperata e stampata sulla pagina utilizzando ajax
. Sono ancora abbastanza nuovo per ajax
e mi chiedevo se qualcuno potesse spiegarmi che cosa fa return false;
alla fine del mio codice? ed è anche necessario?Cosa significa "return false;" fare?
Se inserisco il secondo codice Ajax dopo il return false
il codice non funziona! puoi spiegarmi perché?
//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;
});
interrompe il comportamento di invio modulo predefinito –
@Dagon. Non solo quello. – gdoron