I got the access denied error when i am calling external URL from Ajax call. it is working fine without SharePoint 2010.

    function httpGet(theUrl) {
        var xmlHttp = null;
        xmlHttp = new XMLHttpRequest();
        xmlHttp.open("GET","http://ip.jsontest.com/", false);
        var obj = JSON.parse(xmlHttp.responseText);
        return xmlHttp.responseText;

Please help me to resolve this.

  • Isn't this normal Same-origin policy? Unless that site has CORS enabled. There are ways to solve this, such as CORS, JSONP or app proxy. – eirikb Jan 29 '15 at 7:04
  • i had also tried with jsonp but still its not working – Rajesh Joshi Jan 29 '15 at 7:07
  • Note that the server must implement support for JSONP, it is not automatically given that the server in your example supports this. – eirikb Jan 29 '15 at 7:08
  • 1
    Understanding how the JSONP hack actually works would give you a good idea. This answer on SO should give a good explanation. If it is your server then do consider my two other suggestions as well (CORS and web proxy). – eirikb Jan 29 '15 at 7:14
  • 1
    @RajeshJoshi, you should probably remove sharepoint apps tag in the question. It is misleading as you are working on SP 2010. – Nadeem Yousuf-AIS Jan 29 '15 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.