Now I know there are a few questions around with the same problem but I cannot find a solution, bearing in mind I'm fairly new to JavaScript and/or IIS.
So I have some Java script in an MVC app that when run locally via the Visual Studio IIS express, works a treat with no problems. I also have an IIS site that I have published with exactly the same code. Everything works fine apart from the JavaScript. I am including my script in a Razor view like so:
<script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")" type="text/javascript"></script>
And the following JavaScript is what I am trying to run.
<script>
function executeQuery() {
var url = "/Application/CheckMobileResponse";
debugger;
$.get(url, { applicationId: @Model.ApplicationId, userId : @Model.UserId }, function(response) {
debugger;
//doing some stuff
});
setTimeout(executeQuery, 3000);
}
$(document).ready(function() {
setTimeout(executeQuery, 3000);
});
Basically I am calling an action every 3 seconds and depending on the response I am using window.location.href to redirect to a new view.
I am quite confused because in the console window on google chrome I am getting a 404 server response Error as follows:
Failed to load resource: the server responded with a status of 404 (Not Found) jquery-1.10.2.js:8720
GET http://localhost/Application/CheckMobileResponse?applicationId=1&userId=5 404 (Not Found)
This to me looks like it is finding the jQuery file so may not be a case of not being able to load the JavaScript file. But it is instead failing because it cannot find my action on the GET request (which is odd because this works perfectly on Visual Studio IIS Express).