【发布时间】:2012-04-11 12:00:26
【问题描述】:
我正在使用 jQuery 调用 Web 服务 (c#) 方法。从 Web 服务获取结果后,我必须以 html 形式绑定数据。但问题是,在运行代码时,我从 Web 服务得到延迟响应,直到那时我的函数返回 null 并且没有设置表单字段。 下面是我的代码。在这里,我得到 v 的 null 值
function CallBGHostService(aParam) {
var v = null;
$.ajax({
url: "http://localhost/MyService.asmx/GetBusinessGroupData",
type: 'POST',
dataType: "json",
data: "{'aBusinessGroupID':'" + aParam + "'}",
contentType: "application/json; charset=utf-8",
beforeSend: function (xhr) { xhr.withCredentials = true; },
crossDomain: true,
success: function test(response) {
v = response.d;
alert(response.d);
},
error: function test(response) {
v = response.d;
alert(response.d);
}
});
return (v);
}
【问题讨论】:
-
您可以尝试将您的
data:更改为data: { aBuisnessGroupID: aParam),吗? -
@shaun5 我更改了数据,但随后此服务无法正常工作。
标签: .net web-services jquery