jquery - CORS header 'Access-Control-Allow-Origin' missing -


i'm calling function asp.net form , getting following error on firebug console while calling ajax.

cross-origin request blocked: same origin policy disallows reading remote resource @ http://anotherdomain/test.json. (reason: cors header 'access-control-allow-origin' missing).

var url= 'http://anotherdomain/test.json';         $.ajax({             url: url,             crossorigin: true,             type: 'get',             xhrfields: { withcredentials: true },             accept: 'application/json'         }).done(function (data) {             alert(data);                         }).fail(function (xhr, textstatus, error) {             var title, message;             switch (xhr.status) {                 case 403:                     title = xhr.responsejson.errorsummary;                     message = 'please login server before running test.';                     break;                 default:                     title = 'invalid url or cross-origin request blocked';                     message = 'you must explictly add site (' + window.location.origin + ') list of allowed websites in server.';                     break;             }         }); 

i've done alternate way still unable find solution.

note: i've no server rights make server side(api/url) changes.

this happens when try access domain's resources.

this security feature avoiding freely accessing resources of domain (which can accessed example have exact same copy of website on pirate domain).

when code send request, shall have "200 ok" response code in browser console, means resource accessed, not grant right share resource. not allowing "access-control-allow-origin".

to change that, have write in .htaccess of requested domain file (notyourdomain.com):

    <ifmodule mod_headers.c>     header set access-control-allow-origin "*"     </ifmodule> 

another solution manually copy file server/domain :)

peace , code ;)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -