Ready function not working after ajax response.Below is my code.
function AjaxLoaded() {
$.ajax({
type: 'POST',
url: 'abc.php',
data: dataString,
success: function(result) {
$('document').trigger('ready');
}
});
}
But this is not working at all.Any answers will be appreciated.
Ready function not working after ajax response.Below is my code.
function AjaxLoaded() {
$.ajax({
type: 'POST',
url: 'abc.php',
data: dataString,
success: function(result) {
$('document').trigger('ready');
}
});
}
But this is not working at all.Any answers will be appreciated.
Share Improve this question asked Dec 2, 2014 at 11:10 ThirupathiThirupathi 811 silver badge9 bronze badges 2-
3
You might want to consider using
jQuery.holdReady()
, if it's more relevant to your scenario. – Matt Commented Dec 2, 2014 at 11:13 - 1 Sounds like a xy problem: mywiki.wooledge/XyProblem – A. Wolff Commented Dec 2, 2014 at 11:18
2 Answers
Reset to default 5it should be
$(document).trigger('ready');
not
$('document').trigger('ready');
Still this wont work as jQuery releases all the handlers assigned to ready
event once its been executed.
Edit
You can assign like
$(document).on('ready urmethod',function(){})
And call like
$(document).trigger('urmethod');
Firstly it should be $(document)
, not $('document')
, however that is moot as you cannot manually trigger the ready
event on the document. It only fires once on page load.
If you have some code you want to run after this AJAX call pletes put it in a function and call that instead.
You could use $.holdReady()
however I would suggest not interfering with the firing of base DOM events.