Bunu yapmanın en kolay yolu, onlardan her birinden sonuç alınıyor ve ne sonuçlar yapmayacaksın, her komut dosyası (. Almak veya $. Sonrası ya $) bir $. Ajax göndermek için jQuery kullanmak için.
$(document).ready( function(){
$('#mySubmitButton').click(function(){
//Send data to the email script
$.post( 'send-email.php', $('form').serialize(), function(data, textStatus) {
//data is the result from the script
alert(data);
});
//Send data to the other script
$.post( 'my-other-script.php', $('form').serialize(), function(data, textStatus) {
//data is the result from the script
alert(data);
});
});
});
update:
The serialize command is the data that is being sent. Take a look at the jQuery serialize function. It basically just takes the various inputs, selects, textareas, checkboxes, etc in your form, and puts them into a string like this:
myNameInput = john & aktif = on & whateverSelected = 3
Bu form elemanı adları ve değerleri sadece bir dize var. İşte ajax komutu ile harici komut dosyasına gönderilen budur.
Bir yan not, serialize yaparken, tüm form elemanları değil, sadece bir id bir name niteliği, sahip olduğunuzdan emin olun. Serialize onların id's hiç dikkat etmez. Sadece name.