Pranjal Vatsa

Pranjal Vatsa

  • 2.2k
  • 1
  • 3.3k

Ajax call to a web method does not give response

Aug 8 2013 7:49 AM

I am calling a javascript method from the click of a link:

<a href="#" onclick="get_project_details('<%# Eval("projectIdentifier") %>');"><%# Eval("projectIdentifier") %></a>

The javascript:

  <script type="text/javascript">
        function get_project_details(project_identifier) {
                type: "POST",
                url: "View.asmx/HelloWorld",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                sucess: OnSuccess,
                failure: OnError

        function OnSuccess(data, status) {

        function OnError(request, status, error) {

As you can see, the Ajax call is to a web method HelloWorld() which is inside an asmx page:

        public string HelloWorld()
            return "Hello World";
I do not get a response from the web method. When I try to debug the method by putting a break point, I see that the method is being 'hit'.

But the problem is that the response does not go back to the javascript function. I dont even get an error (OnError() does not give a result).

I tried inspecting the 'onclick' element from the browser and no help from there as well.

Am I missing some settings somewhere. Any kind of help is greatly appreciated.


Answers (1)