控制器操作在$(this).submit()之後不是在completedCallback之後調用。 請參閱下面的代碼。 如何在不使用Ajax的情況下提升完成的回調之前觸發操作?如何在提交事件中提交「已完成」事件?
控制器:
public ActionResult MyFunction(FormCollection data){
//this should trigger before calling the CompletedEvent
}
的JavaScript
var flag = false;
$(form).submit(function(){
if(!flag){
//raise start event
startedCallback.call();
flag = true;
$(this).submit();
//raise completed event
completedCallback.call();
}
});
沒有ajax的意思是什麼?你給出的例子是Asynchronous。如果您提交'同步'表單,則意味着該腳本將在$(this).submit()子句後面退出並跟隨到表單頁面。也許你不想使用xml?或者你使用某種Iframe結構?也許你可以分享一個你想要完成的例子嗎? – Arend 2011-06-02 09:25:04
你知道阿倫德和亞當給你唯一的「正確」的答案,你會得到,對嗎? – jcolebrand 2011-06-05 22:33:50