我为我的Asp.net项目创建了一个Web服务。目前,我通过引用ScriptManager
中的服务从JavaScript访问该服务。但我不想添加ScriptManager
,以便我可以在任何HTML页面中使用它。
答案 0 :(得分:1)
确定。因此,您希望对某些Web服务方法进行ajax调用并将参数传递给它。并且您将以JSON格式
传递参数function CallWebServiceMethod() {
var requestedData = "{ 'LifeCycleN': '" + var_LifeCycleN +//var_LifeCycleN some var represent your data that you want to send
"', 'LiOrder': '" + var_LiOrder +//var_LiOrder again some var represent your data that you want to send
"'}";
$.ajax({
type: "POST",
url: "Services/YouWebServiceName.asmx/WebServiceMethodName",
data: requestedData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {// I 'll assume that your web-service 'll return bool value indicate if the operation done successfully or not.
//do here what you want to do is the request was successful.
}
});
}