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);
}
});
}
See Question&Answers more detail:os