JQuery $ .ajax () json calls the * .js file, makes the browser ask for "save / open",
I can issue $ .ajax () requests for URLs that have the .js extension just fine when I use {... 'dataType': 'script' ...}. However, when I use {... 'dataType': 'json' ...} the browser (Opera and FF, for now, but I'll bet it's generic) asks to save / open the query results.
Note that my "successful" callback works fine and uses the resulting json object just fine.
My question is, should I just remove the * .js extension from the resource and pass the "json = true" parameter? Or is there a convenient way to stop the browser from trying to render / save / open the result? (By hand, I mean, of course, not something that every user has to install in their browser.)
Also note that I am using Rails, so the header routing issue is preventing me from using the Accept header to fix this.
a source to share
I may be wrong, but I suspect you forgot to return false from your event handler. This way your request is propagated to the default handler. Or, as nickf pointed out, an error causing your script to fail. Try wrapping your code in try catch and see if you have any error:
try {
// your code
} catch(e) {
alert(e);
}
a source to share