ajaxForm IE 9 Bug

时间:2012-12-20 19:26:29

标签: javascript jquery ajaxform

var $ajaxForm = $('#form');
$ajaxForm.ajaxForm(function(response) {
     //code
});

这在chrome / firefox / opera / safari中工作正常,但IE 9无法识别提交事件。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

看起来这是asked before。如果这是跨域请求,您可能还想查看this discussion。从那个讨论:

$.ajaxTransport("+*", function( options, originalOptions, jqXHR ) {

    if(jQuery.browser.msie && window.XDomainRequest) {
        var xdr;
        return {
            send: function( headers, completeCallback ) {
                // Use Microsoft XDR
                xdr = new XDomainRequest();
                xdr.open("get", options.url);
                xdr.onload = function() {

                    if(this.contentType.match(/\/xml/)){
                        var dom = new ActiveXObject("Microsoft.XMLDOM");
                        dom.async = false;
                        dom.loadXML(this.responseText);
                        completeCallback(200, "success", [dom]);
                    }else{
                        completeCallback(200, "success", [this.responseText]);
                    }
                };

                xdr.ontimeout = function(){
                    completeCallback(408, "error", ["The request timed out."]);
                };

                xdr.onerror = function(){
                    completeCallback(404, "error", ["The requested resource could not be found."]);
                };

                xdr.send();
          },
          abort: function() {
              if(xdr)xdr.abort();
          }
        };
      }
    });