2

I need to access from a different domaine on a mobile a sharepoint list. Here is my code, a simple get request :

$.support.cors = true;

$(function() {
$().SPServices({
    operation: "GetListItems",
    webURL: "http://myurl.com/project/",
    listName: "PM-Registration",
    CAMLQuery: '<Query></Query>',
    error: function (xhr, message, error) {
          alert('error : ' + error);
    },
    completefunc: function (xData, status) {
        alert('Status: '+status+' xdata: ' + xData.statusText);
        alert('RESPONSE: ' + xData.responseText);
    }
});
});

The problem seems to be CORS blocking the request, but I normally enable it before. It works perfectly with Chrome if I use the command : --args --disable-web-security, and with Safari desktop, but not with Firefox and Safari iOS... I got the error on Chrome without disabling web security :

No 'Access-Control-Allow-Origin' header is present on the requested resource

Am I missing something ? I guess it is a client side problem as it works with Chrome without web security and Safari Desktop

1

Your webURL isn't correct. It probably should be just http://myurl.com/project. You're pointing to the owssvr.dll services, which doesn't have any meaning in an SPServices context.

  • Thanks you for your answer ! Then how can I target the correct list if it's not in the URL ? – Pull May 16 '14 at 13:48
  • You use the listName and webURL combination, as you are doing. You don't need to worry about CORS if you are requesting data within the same Site Collection. In fact, if that's the case, you should use a relative URL, like "/project". – Marc D Anderson May 16 '14 at 14:01
  • I didn't say it but in fact I am on an other domain and I can't change the server seetings (corporate rules....). I deleted the list in the URL but still this CORS error... – Pull May 16 '14 at 14:12
  • Thanks for your answer again, I edited my question with my last test. – Pull May 16 '14 at 16:45
  • Getting same error, did you find any solution? – Ali Oct 2 '14 at 9:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.