Вопрос

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

Это было полезно?

Решение

I will provide an answer to my question.

Even if it work on IE and with specific command on Chrome, this is a security issue set on the server side, only the server can change it by modifing the Access-Control-Allow-Origin

I didn't find a workaround to avoid this CORS problem from the client side. My solution was to move my HTML page on the same domain as my SharePoint. I have now my SharePoint : www.mysharepoint.com, and my mobile webapp www.mysharepoint.com/mobile/index.html

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top