【发布时间】:2014-04-09 04:07:32
【问题描述】:
我有一个函数在成功时调用另一个函数。如您所见,我使用了警报,它上升到警报“2”。
按 F12 时出现 500 服务器错误,但我也可以看到我的 web 服务确实可以工作,因为我看到它正确地以 XML 格式提取所有数据。我的data: param 或查询字符串也得到了正确的值。
JavaScript:
function ContactView()
{
alert("1")
var txtSearchbox = $("#searchTextField").val();
$.ajax({
type: "GET",
data: param = "searchField="+txtSearchbox+"&office="+localStorage.getItem("office")+"&person="+localStorage.getItem("person")+"&user="+localStorage.getItem("user")+"&organization="+localStorage.getItem("organization"),
contentType: "application/json; charset=utf-8",
url: "http://msw-wsdl.company.net/mobile.asmx/ContactGet",
dataType: "json",
success: successContact,
failure: function (msg) {
console.log(msg);
}
});
alert("2") /*this is the last alert that pop's up, nothing further*/
}
/*wsdl call succeed*/
function successContact(data) {
alert("3")
$("#lstView_contacts").kendoMobileListView({
dataSource: JSON.parse(data.d),
template: $("#lstView_contact_Template").html(),
endlessScroll: true,
scrollThreshold: 8
});
window.location = "#contactsview";
}
为什么没有调用成功回调successContact - 有什么想法吗?
【问题讨论】:
-
没有
failure选项,因此当由于相同的来源策略而失败,您没有在控制台中收到“解析错误”消息,请更改它改为error。 -
@adeneo:我得到了更好的错误响应 -
{"readyState":4,"responseText":"{\"Message\":\"There was an error processing the request.\",\"StackTrace\":\"\",\"ExceptionType\":\"\"}","status":500,"statusText":"Internal Server Error"} -
在纠正 500 错误之前,您永远不会成功。检查您发送到服务器的数据,确保其格式正确,以便在服务器端正确使用,而不是产生错误。
-
你从哪里得到错误信息?
标签: javascript jquery