हो सकता है कि वहाँ कोई अंतर नहीं है, लेकिन किसी भी तरह से अन्य की तुलना में बेहतर (या शायद एक रहस्यमय 'तीसरा' जिस तरह से दोनों की तुलना में बेहतर!) है का उपयोग करना चाहिए ...jQuery मैं कई ajaxStart/ajaxStop निपटने
पहली:
var startTime;
$(document).ready(function() {
$("#lbl_ajaxInProgress").ajaxStart(function() {
// store the current date/time...
startTime = new Date();
// update labels
$(this).text('Yes');
$("#lbl_ajaxCallTime").text("-");
});
$("#lbl_ajaxInProgress").ajaxStop(function() {
// update labels
$(this).text('No');
$("#lbl_ajaxCallTime").text(myFunctionThatCalculatesTime(startTime));
});
});
दूसरा:
var startTime;
$(document).ready(function() {
$("#lbl_ajaxInProgress").ajaxStart(function() {
// update labels
$(this).text('Yes');
});
$("#lbl_ajaxInProgress").ajaxStop(function() {
// update labels
$(this).text('No');
});
$("#lbl_ajaxCallTime").ajaxStart(function() {
// store the current date/time...
startTime = new Date();
// update labels
$(this).text("-");
});
$("#lbl_ajaxCallTime").ajaxStop(function() {
// update labels
$(this).text(myFunctionThatCalculatesTime(startTime));
});
});
jQuery 1.8 के रूप में, .ajaxStart() विधि केवल दस्तावेज़ के साथ संलग्न किया जाना चाहिए। – ThdK