Jquery 2.x使用来自Jquery 1.x的ajax代码

时间:2022-02-27 20:33:03

Having a small problem with Jquery, in our system we load a lot of ajax files, we are using a Jquery 2.x, we have a requirement to run offline on IE 9+ so ajax would load from file:/// and it used to work when we were on Jquery 1.x

有一个Jquery的小问题,在我们的系统中我们加载了很多ajax文件,我们使用的是Jquery 2.x,我们需要在IE 9+上脱机运行所以ajax会从file:///加载它我们在Jquery 1.x上时曾经工作过

After doing some digging I found out that Jquery 2.x has dropped activeX support. Which is what I need to get the JSON files on IE. So my question is, is there a way of having Jquery 2.x and then just after it load only the ajax code for Jquery 1.x?

在做了一些挖掘后,我发现Jquery 2.x已经放弃了activeX支持。这是我在IE上获取JSON文件所需要的。所以我的问题是,有没有办法让Jquery 2.x然后只加载Jquery 1.x的ajax代码?

1 个解决方案

#1


0  

I have solved my own problem by discovering $.ajaxTransport which allows you to implement your own ajax functionality. Thanks to this I was able to check if ActiveX is supported and add the necessary logic to make everything work.

我通过发现$ .ajaxTransport解决了我自己的问题,它允许你实现自己的ajax功能。多亏了这一点,我能够检查是否支持ActiveX并添加必要的逻辑以使一切正常。

$.ajaxTransport( "* text html xml json", function( options, originalOptions, jqXHR ) {
            if( /* perform check here for scenario your trying to fix*/) {
                return {
                  send: function( headers, completeCallback ) {
                      //create your logic here and have it return 
                      completeCallback(status, statusText, responses, headers);
                  },
                  abort: function() {}
                };
              }
        });

#1


0  

I have solved my own problem by discovering $.ajaxTransport which allows you to implement your own ajax functionality. Thanks to this I was able to check if ActiveX is supported and add the necessary logic to make everything work.

我通过发现$ .ajaxTransport解决了我自己的问题,它允许你实现自己的ajax功能。多亏了这一点,我能够检查是否支持ActiveX并添加必要的逻辑以使一切正常。

$.ajaxTransport( "* text html xml json", function( options, originalOptions, jqXHR ) {
            if( /* perform check here for scenario your trying to fix*/) {
                return {
                  send: function( headers, completeCallback ) {
                      //create your logic here and have it return 
                      completeCallback(status, statusText, responses, headers);
                  },
                  abort: function() {}
                };
              }
        });