I call the getResult()
function everytime when res.reply = 2
, but there are cases that res
is empty. When the returned value is empty console.log("error")
is invoked. This works in older versions of jQuery Mobile. Now the version is 1.3.2.
function getResult()
{
request = $.ajax({
type: "POST",
url: url,
dataType: "json",
data: {
....
},
error: function() {
console.log("error");
},
success: function(res) {
if(res.reply=='2') {
getResult();
}
}
});
}
dataType: "json"
means: give me json, nothing else. an empty string is not json, so recieving an empty string means that it wasn't a success...
request = $.ajax({
type: "POST",
url: url,
data: {
....
},
error: function() {
console.log("error");
},
success: function(res) {
var response = jQuery.parseJSON(res);
if(typeof response == 'object'){
if(response.reply == '2') {
getResult();
}
} else {
//response is empty
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With