所以我有这个代码调用包含局部视图的弹出对话框。问题是每当我调用对话框时,div.load会将整个字符串块附加到主控制器的地址。
function OpenSendMessagePopUp() {
var div = $("#DivAppendToPartialView");
div.load("@Url.Content(~/Resend/_SendMessage.cshtml)", function () {
div.dialog({
modal: true,
width: 500,
height: 420,
show: 'blind',
hide: 'blind',
title: "Send Message",
draggable: false,
resizable: false,
buttons: {
"Cancel": function () {
$(this).dialog("close");
}
}
});
});
}
function SaveMessage() {
$.ajax({
type: 'POST',
url: '@Url.Content("~/Resend/_SendMessage.cshtml")',
data: {
smsContentId: smsContentId,
comments: comments
},
});
MobileNumberUpload是项目的主控制器,而Resend是部分视图的控制器。请注意,我不能根据项目的约束组合两个控制器。
答案 0 :(得分:0)
尝试以下更改:
function OpenSendMessagePopUp() {
var div = $("#DivAppendToPartialView");
div.load('@Url.Content("~/Resend/_SendMessage.cshtml")', function () {
div.dialog({
modal: true,
width: 500,
height: 420,
show: 'blind',
hide: 'blind',
title: "Send Message",
draggable: false,
resizable: false,
buttons: {
"Cancel": function () {
$(this).dialog("close");
}
}
});
});
}
function SaveMessage() {
$.ajax({
type: 'POST',
url: '@Url.Content("~/Resend/_SendMessage.cshtml")',
data: {
"smsContentId": smsContentId,
"comments": comments
},
});
}
还要确保在JS中声明 smsContentId 和评论。