I've added "async:false" on my ajax code, for a remote function, but it pushes everything that comes before it.
This is the code going on:
function load() {
$("#Load").show(0,function(){
console.log('Spinner Loaded');
});
}
function unload() {
$("#Load").hide();
console.log('Load Ended');
}
function server(datasend) {
load();
var response;
$.ajax({
type: 'POST',
url: 'http://mailsnitch.ipx-il.com/get/index.php',
dataType: 'json',
timeout:4000,
async: false,
data: datasend,
success: function(valueable){
console.log('Success');
response = valueable;
console.log(valueable);
},
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error.\n' + jqXHR.responseText);
}
},
});
unload();
return response;
}
Im calling server()
, and the order should be: load();$.ajax();unload();
The acctual order is $.ajax();load();unload();
Please help :)
Thx, Amit.