带有 Web 服务的 HTTP 500 错误 jQuery Ajax [英] HTTP 500 Error jQuery Ajax with Web service
问题描述
我在单个 Visual Studio 解决方案中有两个简单的项目来了解 jQuery ajax 请求的工作原理.一个是 Web 服务,第二个是使用 Web 服务的项目.
您可以从这里下载非常小的项目. 解释).如果我理解错了或者有人想分享更多关于它的内容,那么欢迎他们:)
有关更多信息,您可以查看此链接
更好的选择是在项目中保留一个 Web 服务,并将其他 Web 服务(需要)调用到项目的 Web 服务中.
I have two simple projects in a single Visual Studio solution to understand how a jQuery ajax request works. One is a web service and the second one is a project consuming the web service.
You can download the very small project from here. Download Project file
As you can see in the project, Whenever I try to call the Web Service, Internal Server Error 500 is occurring.
In chrome, I can see the following alert (executed by "Error" function of Ajax call)
Please assist me to find the problem..
EDIT:
function btnClick() {
debugger;
var txtValue = $('#txtValue');
var text = txtValue.val();
//
//
$.ajax({
url: "http://localhost:12000/ExampleJsonWS.asmx/getValue",
type: "POST",
dataType: "json",
data: "{" + txtValue.val() + "}",
timeout: 30000,
async: false,
contentType: "application/json; charset=utf-8",
success: function (data) {
debugger;
alert(data);
return data;
},
error: function (result) {
debugger;
//alert(e);
alert(result.status + ' ' + result.statusText);
}
});
}
The problem was that its not possible to POST with keeping the web service in different project while a GET can do that. (Explained by Phillip Haydon). If I understand it wrong or someone want to share more about it, then they are welcome :)
For more info you can have a look at this link
The better alternative is to keep a Web service inside the project and call the other Webservice (which is needed) into the Project's web service.
这篇关于带有 Web 服务的 HTTP 500 错误 jQuery Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!