1
function dispatchVehicle(){
if(!chickAll()){
return false;
}
var action = window.url + '?&method=dispatchVehicles'
+ "&conLclFlag=" + conLclFlag
+ "&containerId=" + containerId
+ "&vehicleNameFlag=1"
+ "&t=" + (new Date()).getTime();
jQuery.getJSON(action, $('#vehicleForm').serialize(), function(data) {
if(data.flag){
if (window.confirm(data.message)) {
alert(1);
var action1 = window.url + '?&method=dispatchVehicles'
+ "&conLclFlag=" + conLclFlag
+ "&containerId=" + containerId
+ "&vehicleNameFlag=2"
+ "&t=" + (new Date()).getTime();
alert(2);
jQuery.getJSON(action1, $('#vehicleForm').serialize(), function(data1) {
alert(3);
if(!data1.flag){
alert(data1.message);
}
if (data1.succ) {
window.parent.location.reload();
window.parent.ClosePop();
}
});
}
}
if (data.succ) {
window.parent.location.reload();
window.parent.ClosePop();
}
});
}
我需要通过jQuery的getJSon函数执行两个ajax调用。
问题是,一旦执行其中一个调用并且data.flag为true,则调用第二个getJSon函数(因为我需要第一个调用的结果作为第二个调用中的一个条件)。 但是当函数运行时,代码“alert(3)”不能执行。
任何帮助将不胜感激。
在筑巢它,尝试建立回调阵列代替。 – 2012-03-01 09:58:42
你的动作1的字符串是什么。你可以发布它,frebug中的任何JavaScript错误 – 2012-03-01 10:00:14