Monday 15 August 2011

jquery - Cross domain error even when ajax called made from same domain -


I am calling an AJAX call to check the username. URL to call is hard in JS file. E.g.

Now when I call it from AJAX, it works fine, but if I call, it returns a cross domain error.

XMLHttpRequest can not load. Origination is not allowed by access-control-permission-origin.

How do I solve it? Is the only way to jsonp?

Have you tried to set an alternative HTTP header value when your service data is returned : Access-Control-Permission-Origin: * Access-Control-Permission-Header: "Content-Type, Ex-Requested, X-Auth-Token" Code>

You do not need to create access-control-permission-origin: * You may possibly be more restrictive. But we tried to check that it would work.

Just to clarify - we still use json and not jsonp

No comments:

Post a Comment