下面是我需要使用 ajax 访问的 web 方法:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string CallConfiguredWebService(String projectID,String workType,String Page,String Action,String webServiceName,Object[] arguments)
{}
我尝试使用以下代码从脚本访问它。
var args = [2];
args[0] = "Hai";
args[1] = "Saranya!!";
$.ajax({
url: "../../Services/ValidationService.asmx/CallConfiguredWebService?",
method: "POST",
data: JSON.stringify({ projectID: '302',workType: 'LFAT',Page: 'Create', Action: 'Create', webServiceName: 'WebService195174',arguments: args}),
dataType: 'json',
contentType: 'application/json',
success: fnsuccesscallback,
error: fnerrorcallback
});
我收到以下错误:
500 - Internal server error No service found at /Services/ValidationService.asmx
.
我很确定网址是正确的。
我从类似的帖子中了解到,这可能是因为 ajax 调用中的参数不匹配。
我无法弄清楚我的代码中的确切错误是什么。
也试过用JSON.stringify
。
请帮助您的专业知识。
更新:
重新部署 Web 应用程序后,ajax 调用开始工作。