function myfunction() {
...
$(myarray).each(function() {
...
$.ajax({
...,
async: false,
error: function() {
// I want to return false and quit from this function here
// no luck with return false, still continuing to the next loop
}
});
};
}
答案 0 :(得分:2)
使用变量:
function myfunction() {
var gotError=false;
$(myarray).each(function() {
if(gotError) return;
$.ajax({
...,
async: false,
error: function() {
gotError=true;
}
});
};
return !gotError;
}