I am trying to call asmx service On server from jQuery function like the following:
$('.myButton').click(function() {
$.ajax({
type: "POST",
url: "/http://myserver/service.asmx/GetProgramCategories",
cache: false,
contentType: "application/x-www-form-urlencoded",
data: "{}",
dataType: "json",
success: handleHtml,
error: ajaxFailed
});
});
function handleHtml(data, status)
{
for (var count in data.d)
{
alert(data.d[count].Author);
alert(data.d[count].BookName);
}
}
function ajaxFailed(xmlRequest)
{
alert(xmlRequest.status + ' \n\r ' +
xmlRequest.statusText + '\n\r' +
xmlRequest.responseText);
}
I have debugged but it give me error 500 Internal Server Error
and the server descriptor like the following:
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.
POST /service.asmx/GetProgramCategories HTTP/1.1
Host: myhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length
username=string&password=string
HTTP/1.1 200 OK
any one can help please?
hey finally I got the answer
this is the code: