My function is like this
// JavaScript Document
$('#MyFormSubmit').submit(function(){
try{
/* Ajax - 1 */
$.ajax({
url: 'Any',
type: 'GET',
data: 'ID',
contentType: "application/json;charset=utf-8",
success: function (data) {
alert("Success - 1");
},
error: function (x, y, z) {
alert("Error - 1");
}
});
/* Ajax - 2 */
$.ajax({
url: 'Any',
type: 'GET',
data: 'ID',
contentType: "application/json;charset=utf-8",
success: function (data) {
alert("Success - 2");
},
error: function (x, y, z) {
alert("Error - 2");
}
});
/* Ajax - 3 */
$.ajax({
url: 'Any',
type: 'GET',
data: 'ID',
contentType: "application/json;charset=utf-8",
success: function (data) {
alert("Success - 3");
},
error: function (x, y, z) {
alert("Error - 3");
}
});
}
catch(e){
alert(e);
}
});
where 1 get first error, then I want stop execution of next ajax ? How to do ?
Within the error block of first ajax call, just add return false.
error: function (x, y, z) {
alert("Error - 1");
return false;
}
Plese Write Code in this way
function fnMyFunction1(){
try{
if(success){
// call fnMyFunction2
}
else{
// Show Error message
}
}
catch(e){
// Show Exception message
}
}
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