我有一个函数在成功时调用另一个函数。正如您所看到的,我已经使用了警报,它上升到警报“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
没有被调用 - 有什么想法吗?
最佳答案
函数 successContact
仅在成功时才会被调用,错误 500 表示未成功。将调用 error
方法,而该方法未在您的案例中定义。
关于javascript - 函数不调用其他函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22947042/