好日子大家,jQuery的AJAX调用失败5
我有一个CSHTML文件jQuery的AJAX方法,从服务器中检索数据并显示在一个模式对话框。该方法如下:
$("#flowButton").click(function() {
debugger;
var $buttonClicked = $(this);
var id = $buttonClicked.attr('data-id');
var options = { "backdrop": "static", keyboard: true };
$.ajax({
type: "GET",
url: '@Url.Action("GetSentEntryFlow", "Inbox")',
contentType: "application/json; charset=utf-8",
data: $('#inboxSentForm').serialize(),
datatype: "json",
success: function (data) {
debugger;
$('#flowModalContent').html(data);
$('#flowModal').modal(options);
$('#flowModal').modal('show');
},
error: function() {
alert("Dynamic content load failed.");
}
});
});
这时候我使用的LocalDB数据源工作正常,但是当我更改连接字符串使用时显示错误消息的远程数据库。我知道连接到远程数据库是可以的,因为项目的其他部分都可以很好地使用它,只有这种方法失败。
我的视图代码是这样的:
@foreach (var itemGroup in Model.Entries)
{
int childCount = itemGroup.Count();
<tr>
<td class="text-center">
@Html.Hidden(string.Format("sentEntries[{0}].Id", rowNumber - 1), itemGroup.First().Id, new { @id = string.Format("sentEntries[{0}].Id", rowNumber - 1) })
@Html.CheckBox(string.Format("sentEntries[{0}].Selected", rowNumber - 1), itemGroup.First().Selected, new { @id = string.Format("sentEntries[{0}].Selected", rowNumber - 1) })
</td>
<td>
@(rowNumber++)
</td>
<td>
@Html.DisplayFor(modelItem => itemGroup.First().EntryType.TypeFA)
</td>
<td>
@itemGroup.First().GetEntrySubject()
</td>
</tr>
foreach (var item in itemGroup.Skip(1))
{
<tr>
<td class="text-center">
@Html.Hidden(string.Format("sentEntries[{0}].Id", rowNumber - 1), item.Id, new { @id = string.Format("sentEntries[{0}].Id", rowNumber - 1) })
@Html.CheckBox(string.Format("sentEntries[{0}].Selected", rowNumber - 1), item.Selected, new { @id = string.Format("sentEntries[{0}].Selected", rowNumber - 1) })
</td>
<td>
@(rowNumber++)
</td>
<td>
@Html.DisplayFor(modelItem => item.EntryType.TypeFA)
</td>
<td>
@item.GetEntrySubject()
</td>
</tr>
}
}
,并在控制器方法是这样的:
public ActionResult GetSentEntryFlow(List<DataTableRow> sentEntries)
{
DataTableRow selectedRow = sentEntries.FirstOrDefault(i => i.Selected == true);
InboxSentEntry selectedSentEntry = InboxSentEntryRepository.GetById(selectedRow.Id);
ICollection<InboxReceivedEntry> firstLevelFlow = InboxReceivedEntryRepository.GetFirstLevelFlowByEntryId(selectedSentEntry.EntryId);
return PartialView("~/Views/Shared/Modals/_EntryFlowModalPartial.cshtml", firstLevelFlow);
}
是我得到它显示在边缘的开发工具部分的错误是这样的:
HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier). (XHR)GET - http://localhost:51527/Inbox/GetSentEntryFlow?__RequestVerificationToken=-jXt8frpCtnoDPMwd9eo1DUYn7T3ud6BVjsCGukmu7KwMnkgV-i26zKt68b5MIUOqrwkb__otyTvEKprDHAktqJl_T0sQuyS5WPSdX0ET8xx7RggVuDaz45Z_xE1a5OR7cQ5DAfTR4ygt3TmSZJ8fw2&dt_inbox_length=50&EntryTypeFilterInput=&EntryTypeFilterSelect=&EntryActionTypeFilterInput=&EntryActionTypeFilterSelect=&EntryPriorityFilterInput=&EntryPriorityFilterSelect=&sentEntries%5B0%5D.Id=0ff4995d-61da-4896-a30b-ce597090a26b&sentEntries%5B0%5D.Selected=true&sentEntries%5B0%5D.Selected=false&sentEntries%5B1%5D.Id=4274317e-59f4-4f06-8527-d7976f061b3d&sentEntries%5B1%5D.Selected=false
当前窗口:本地主机/收件箱/发送
任何想法是什么导致了这个问题? 在此先感谢
当您浏览控制器时,您会收到什么错误消息? – nurdyguy
如果您单击请求并查看响应,您也可能能够在网络选项卡上看到堆栈跟踪。 – nurdyguy
代码执行根本没有得到控制器。它停在jquery上。我会将jquery错误添加到帖子中。 –