我想跳過所有這段代碼,如果一些先決條件不滿足,但我也想移動函數中括號之間的所有代碼。它允許嗎?我不明白這個語法是如何工作的。製作JQuery ajax請求有條件的
$.ajax({
type: "POST",
url: urlAppend,
data: JSON.stringify(xxx),
contentType: "application/json; charset=utf-8",
dataType: "json",
processdata: false,
success: function (result) {
if (canceled) {
return;
}
//Long code
}
//Long code 2
},
error: function (request, error) {
alert('ppp');
}
});
是的,你可以..你甚至嘗試? – codepixlabs 2014-10-29 15:29:47
你想跳過'$ ajax'整個調用嗎?你不能只是在'if'語句中包裝該代碼嗎? – Lix 2014-10-29 15:29:51
@Lix:是的,我不希望Ajax被調用。 – Revious 2014-10-29 15:31:00