0

We have proxy implemented in our office, I need to make webservice call using jQuery AJAX.

If we skip proxy, the web method gets called without any errors.
But the moment we enable proxy, we get "NetworkError" no more details available regarding this error.

We cannot disable proxy forever, now we want to call this webservice using jQuery AJAX.
Please help me resolve the issue.

var surl = "http://www.mydomain.com/MyJSONService/Service.asmx/HelloWorld";
$.ajax({
    type: 'GET',
    url: surl,
    crossDomain: true,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    xhrFields: {
         withCredentials: true
    },
    success: function(data, statusCode, xhr) {
        alert(data.d);
    },
    error: function(xhr, status, error) { 
        alert('Error !!'); 
    },
    async: false,
    cache: false
});
user3568666
  • 11
  • 1
  • 6
  • The proxy should be configured in your browser. AJAX calls are made by the browser. So as long as the browser is configured to go via the proxy, it should not be a problem. – AdityaKeyal Apr 27 '14 at 14:49
  • Thanks for your comment Aditya, it seems to be working after enabling async. Now I have a new problem: I get a an error with status code 0, the responseText is empty and i cannot get any more details regarding this error. – user3568666 Apr 28 '14 at 05:46
  • Look at [this link for more details.](http://stackoverflow.com/questions/2000609/jquery-ajax-status-code-0) – AdityaKeyal Apr 28 '14 at 05:56
  • It didnt work out, I set all the settings in web.config, still facing error with status code 0. If i deploy service on local computer, it is working fine, when i put it on test server it gives me error. – user3568666 Apr 28 '14 at 06:55
  • It seems to be more a browser blocking issue than local. The browser is blocking your request. Try to use the net monitor in IE/FF to find what is the exact reason for blocking. – AdityaKeyal Apr 28 '14 at 06:59
  • Yes there is some problem in Request type, it automatically changes to 'OPTIONS' as i see from Firefox. When I change request type to GET by editing it in Firefox, it gives me status code of 200 which is absolutely fine. But can i change the request type to GET, as u can see I have mentioned the request type as GET only. I dont know how and where it gets changed. – user3568666 Apr 28 '14 at 07:30
  • Read [this](http://stackoverflow.com/questions/1099787/jquery-ajax-post-sending-options-as-request-method-in-firefox) and [this](http://stackoverflow.com/questions/1256593/jquery-why-am-i-getting-an-options-request-instead-of-a-get-request) it seems to be a standard in cross domain requests. – AdityaKeyal Apr 28 '14 at 08:21
  • Thanks for your comments and extended help. I have changed it to accessing webservice from service side as it was consuming lot of time. – user3568666 May 01 '14 at 14:29

0 Answers0