Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling Web Service from AJAX
    text
    copied!<p>I am trying to call a Web Service method from AJAX call. Its working fine if I use 'localhost'. But, If I replace the 'localhost ' with specific IP address its giving me some script error.</p> <p><strong>My code:</strong></p> <pre><code> $.ajax({ url: "http://localhost:1265/Service.svc/rh/VerifyConfirmationCode", type: "GET", datatype: "jsonp", data: { confirmationcode: 'MYCODE' }, success: OnSuccess, error: OnError }); function OnSuccess(data, status) { alert(data); } function OnError(request, status, error) { alert('error'); } </code></pre> <p>Interface IService.cs :</p> <pre><code> [OperationContract] [WebGet(UriTemplate = "/VerifyConfirmationCode?confirmationcode={confirmationCode}", ResponseFormat = WebMessageFormat.Json)] bool VerifyConfirmationCode(string confirmationCode); </code></pre> <p>Class Service.cs</p> <pre><code> public bool VerifyConfirmationCode(string confirmationCode) { return (confirmationCode.equals("MYCODE")); } </code></pre> <p>In the above code, If I change the URL to </p> <pre><code>url: "http://192.168.1.1:1265/Service.svc/rh/VerifyConfirmationCode" </code></pre> <p>I'm getting follwing errors,</p> <blockquote> <p><strong>'Microsoft JScript runtime error: Access is denied'</strong> in the line 'w.open(m,e.url,e.async);' and <strong>'Microsoft JScript runtime error: Could not complete the operation due to error c00c023e'</strong> in the lines 'w.setRequestHeader("Content-Type",e.contentType);' and w.setRequestHeader("Accept", e.dataType&amp;&amp;e.accepts[e.dataType]?e.accepts[e.dataType]+", <em>/</em>":e.accepts._default) </p> </blockquote> <p>of jquery-1.4.1.min.js file</p> <p>Please help me to resolve it.</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload