I am trying to set up automatic JSLint tests that will grab js files from a target website, and then using Selenium run it against a Test site that will perform JSLint tests using the url of the Js file.
I am running into problems trying to test this locally, with two different localhost websites.
$(function () {
$.ajax({
url: "http://code.jquery.com/jquery-latest.min.js",
//url: "http://localhost:62338/Scripts/test.js", // url to other local site
dataType: "text"
}).done(function (data) {
var myResult = JSLINT(data);
..
});
});
If I run the above code with the url pointing at the jquery url, it works fine and JSLint analyses this file. But it is breaking if I try to point it at my the js file in my other localhost site. If I view the Network Inspector in Chrome, it says the call to the script was cancelled.
Any ideas why I am not able to access the locally hosted js file in this way?
I am using an MVC4 Web Project, by the way.
Edit: I had no luck with Cors or pointing to my IP, but Dominic's answer eventually led me to this question, where I am able to disable security on Chrome. I don't like this option at all, but its just to test locally before I get all the TeamCity stuff setup, and the change is undone as soon as Chrome is restarted.
Edit2: The 2nd answer on this question also worked for me, by adding:
<httpProtocol>
<customHeaders>
<clear />
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
..to the target site's web.config I was able to get this to work without having to disable security on Chrome. And as the target site is just a dummy site and is being used locally this works much better for me.