javascriptsame-origin-policycross-domain-policy

same origin policy in javascript


 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>   

Here also we are acessing a resource from another domain.
But here we didnt get any problem due to same origin policy. So, does the script tag capable of accessing the resource from other domin?


Solution

  • The SCRIPT tag is HTML, and really has nothing to do with JavaScript on it's own. Just like the IMG tag, it has nothing to do with same origin policy

    As soon as you start using JavaScript, you will get some origin policy issues, and then you'll need headers() on the API side, or JSONP