//页面请求的参数配置
var Config = {
ServiceUrl: "/Core/WebService/MobileService.asmx/"
};
//[ 调用简单类型 ]
function Test1()
{
var username = "admin";
var password = "admin";
$.ajax(
{
type: "post",
url: Config.ServiceUrl + "Query4Login",
data: "{ userName:'" + username + "', pwd: '" + password + "' }",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result)
{
alert(result.d);
}
}
);
}
//[ 调用自定义复杂类型 ]
function Test2()
{
$.ajax(
{
type: "post",
url: Config.ServiceUrl + "Query",
data: "{}",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result)
{
var search = result.d;
var showText = [];
for (var s in search)
{
showText.push(s + ":" + search[s]);
}
alert(showText.join("\r\n"));
}
}
);
}
//[ 调用自定义复杂类型集合(xml形式) ]
function Test3()
{
$.ajax({
url: Config.ServiceUrl + "QueryList",
data: {},
contentType: "application/xml",
type: "post",
dataType: "xml",
success: function (data)
{
$("EntSearchLog", data.documentElement).each(
function (i)
{
alert($(this).find("Id").text() + "\t"
+ $(this).find("KeyWords").text() + "\t"
+ $(this).find("SearchTime").text() + "\t"
+ $(this).find("IsDeleted").text()
);
}
);
}
}
);
}
//[ 调用自定义复杂类型集合(Json形式) ]
function Test4()
{
$.ajax({
url: Config.ServiceUrl + "QueryList",
data: {},
contentType: "application/json",
type: "post",
dataType: "json",
success: function (result)
{
$(result.d).each(function (i)
{
alert(this.Id + "\t" + this.UserId + "\t" + this.KeyWords + "\t" + this.IsDeleted);
});
}
}
);
}
jQuery 调用WebService - 》 各种格式的调用
最新推荐文章于 2019-09-23 10:21:00 发布