【发布时间】:2011-04-20 07:39:01
【问题描述】:
目前我有一个按钮,它使用 jQuery/AJAX 从 SharePoint 列表中搜索所有客户,并且我的 Web 服务返回一个 XML 字符串。然后,我使用 XML 中的数据填充下拉列表。
我知道想为搜索功能传递一个参数(客户名称),我可以从 SharePoint 列表中返回我想要的内容,但我的 AJAX 调用返回错误 (parseerror)。
获取所有客户(可行):
$.ajax({
type: "GET",
url: "SynchroniseCustomers.asmx/GetAllCustomers",
dataType: "text/xml",
error: function (xhr, status) {
hideLoading();
},
beforeSend: function () {
showLoading("customers");
},
success: function (xml) {
hideLoading();
populatecustomerDropdownList($(xml).text());
}
});
我不知道该怎么做,但我试过了
var customer = CustomerName;
$.ajax({
type: "GET",
data: { CustomerName: JSON.stringify(customer) },
url: "SynchroniseCustomers.asmx/GetCustomerByName",
dataType: "json",
error: function (xhr, status) {
hideLoading();
alert(xhr + " " + status);
},
beforeSend: function () {
showLoading("Customers");
},
success: function (xml) {
hideLoading();
populateCustomerDropdownList($(xml).text());
}
});
有人可以为我指出如何执行此操作的正确方向吗?
提前致谢。
【问题讨论】:
标签: javascript jquery ajax