Jquery $.ajax() json call to *.js file causes browser to ask 'save/open'

I'm able to issue $.ajax() requests to urls that have a '.js' extension just fine when I use {...'dataType' : 'script'...}. However, when I use {...'dataType' : 'json'...} the browser (Opera and FF, so far, but I'll bet it's universal) asks to save/open the results of the request. Note that my 'success' callback runs fine and uses the resulting json object just fine. My question is, should I just drop the *.js extension from the resource and pass a 'json=true' option? Or is there a handy way to stop the browser from trying to render/save/open the result? (By handy I mean, of course, not something that every user has to set in their browser.) Also note that I'm using Rails, so the header order routing issue prevents me from using an Accept header to fix this.

以上就是Jquery $.ajax() json call to *.js file causes browser to ask 'save/open'的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准