ajaxSubmit 与 SimpleModal 结合使用不会触发成功委托
使用以下代码,我尝试在 ajaxSubmit 之后执行一些操作,但成功委托永远不会被触发。 ajaxSubmit 代码到达 asp.net 控制器,该控制器成功处理带有 JSON 结果的请求。模型表单包含一个执行 AjaxSubmitAndClose 的按钮。
function ShowModal(rendercontainerid, modalcontainerid, url) {
if (url == '')
return;
$.get(url, function(data) {
$(rendercontainerid).html(data);
$(rendercontainerid).modal({
close: false,
containerId: modalcontainerid
});
});
}
function AjaxSubmitAndClose(formid) {
var options = {
beforeSubmit: showRequest,
success: showResponse,
dataType: 'json'
};
$(form).ajaxSubmit(options);
}
function showRequest(formData, jqForm, options)
{
$('#formSub').html('We really appreciate your feedback!');
var queryString = $.param(formData);
alert('About to submit: \n\n' + queryString);
return true;
}
function showResponse(responseText, statusText)
{
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
With the following code I'm trying to execute some actions after the ajaxSubmit, but the success delegate is never fired. The ajaxSubmit code reaches the asp.net controller who succesfully handles the request with an JSON result. The model form contains an button who executes the AjaxSubmitAndClose.
function ShowModal(rendercontainerid, modalcontainerid, url) {
if (url == '')
return;
$.get(url, function(data) {
$(rendercontainerid).html(data);
$(rendercontainerid).modal({
close: false,
containerId: modalcontainerid
});
});
}
function AjaxSubmitAndClose(formid) {
var options = {
beforeSubmit: showRequest,
success: showResponse,
dataType: 'json'
};
$(form).ajaxSubmit(options);
}
function showRequest(formData, jqForm, options)
{
$('#formSub').html('We really appreciate your feedback!');
var queryString = $.param(formData);
alert('About to submit: \n\n' + queryString);
return true;
}
function showResponse(responseText, statusText)
{
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 ASP.NET,我相信您需要使用模式的
appendTo:'form'
选项:If you are using ASP.NET, I believe you need to use the
appendTo:'form'
option for the modal:在调查这种奇怪的行为后,我发现了一个开放的 bug。
然后我在露天拍摄了一张照片,并从选项中删除了数据类型
对象,令人惊讶的是一切又恢复正常了。
After investigating this strange behavior I found an open bug.
Then I did a shot in the open and I removed dataType from the Options
object and surprisingly everything was working again.