它是不好的做法,直接从一个jQuery插件,做一个Ajax请求? [英] Is it bad practice to do an Ajax request directly from a jQuery plugin?

查看:148
本文介绍了它是不好的做法,直接从一个jQuery插件,做一个Ajax请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在写一个jQuery插件,在很大程度上依赖于使用URI内容的出口。只需使用JavaScript的,它工作正常,在所有非IE浏览器。有在下载IE使用ActiveX事情的方法,但它常常块,于是我发现,我可以通过PHP只能下载使用IE浏览器。因此,对于所有非IE浏览器,我会用JS,但我会做Ajax和IE浏览器。这将是一个坏/低效率的做法?

So I'm writing a jQuery plugin that relies heavily on content exports using URIs. Using just JavaScript, it works fine on all non-IE browsers. There is a method of downloading things using ActiveX in IE, but it frequently blocks that, so I found that I can only download through PHP with IE. So for all non-IE browsers I would use JS, but I would do Ajax with IE. Would this be a bad/inefficient practice?

推荐答案

我猜测您要下载的文件?这可能是这些下载的其他浏览器,因为其他浏览器都在猜测文件类型(例如图像,文档等)。

I am GUESSING that you are trying to download files? It is possible that these downloads work on other browsers because the other browsers are GUESSING as to the type of file (i.e. image, document etc.).

如果没有MIME类型(如图像/ PNG)或内容类型(应用程序/ JavaScript的)在HTTP响应头被设置,那么这将无法在IE浏览器,因为IE浏览器(在这种特定的情况下, )实际上试图遵循的标准,并且不承担任何与该文件。

If no MIME-TYPE (such as "image/png") or CONTENT-TYPE ("application/javascript") is set in the HTTP response headers, then this will NOT work in IE because IE (in this specific case) actually tries to follow standards and doesn't assume anything to do with the file.

这篇关于它是不好的做法,直接从一个jQuery插件,做一个Ajax请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆