helo im trying to check if a html is appended to a id, im not sure about the best way to do this in javascript, heres a snippet what i have made so far
var appendstatus= 0;
$.ajax({
type: "GET",
url: params['content'],
dataType: 'text',
success: function(data) {
// append the html
$(params["id"]).append(data);
// is this the right way to check it ?
appendstatus= 1;
}
});
// got an 0, so its not global?
console.log(appendstatus);
// do some jobs after the html is appended on the div id
the question is what is the best way to check some data is appended in this case ?
thanks for helping out
Adam Ramadhan
Because your AJAX request is asynchronous, the
console.log()happens before the response is received.Any code that relies on the successful response must be placed in (or invoked from) the
success:callback.Order of execution: