javascript - Referencing Js script in one localhost site, from another localhost site -


i trying set automatic jslint tests grab js files target website, , using selenium run against test site perform jslint tests using url of js file.

i running problems trying test locally, 2 different localhost websites.

 $(function () {        $.ajax({         url: "http://code.jquery.com/jquery-latest.min.js",         //url: "http://localhost:62338/scripts/test.js", // url other local site         datatype: "text"       }).done(function (data) {         var myresult = jslint(data);         ..       });     }); 

if run above code url pointing @ jquery url, works fine , jslint analyses file. breaking if try point @ js file in other localhost site. if view network inspector in chrome, says call script cancelled.

any ideas why not able access locally hosted js file in way?

i using mvc4 web project, way.

edit: had no luck cors or pointing ip, dominic's answer led me question, able disable security on chrome. don't option @ all, test locally before teamcity stuff setup, , change undone chrome restarted.

edit2: 2nd answer on question worked me, adding:

<httpprotocol>       <customheaders>         <clear />         <add name="access-control-allow-origin" value="*" />       </customheaders>     </httpprotocol> 

..to target site's web.config able work without having disable security on chrome. , target site dummy site , being used locally works better me.

this due same origin policy not letting ajax calls go localhost. might fixed changing below setting before making call.

jquery.support.cors = true 

you might able around changing localhost computer's ip.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -