简体   繁体   English

Ajax.Request在Chrome中不起作用

[英]Ajax.Request not working in Chrome

Below ajax request working in all browsers but not in chrome version 28.XX. 在ajax下面,要求可在所有浏览器中使用,但不能在chrome版本28.XX中使用。 Someone please tell me,what is wrong with this code? 有人请告诉我,这段代码有什么问题?

     var output = '';

      $.ajax({
        url      : "PageController/CurrencyController.php",
        data     : formData,
        dataType : "text",        
        async    : false,
        success  : function(html, textStatus, XMLHttpRequest) {
                   alert(" ajax done"+html);
            if ( html != '' ) {
                output = html;
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
             alert("Req "+XMLHttpRequest +" status "+textStatus+"  Error "+errorThrown);
        }
});

alert(" ajax done"+html); does not work in Chrome but gives popup in other browsers. 在Chrome中不起作用,但会在其他浏览器中弹出。

Maybe the problem is using XMLHttpRequest as a function parameter name. 也许问题是使用XMLHttpRequest作为函数参数名称。 That is a reserved word. 那是保留字。 Try changing it xhr . 尝试将其更改为xhr

 var output = '';

 $.ajax({
    url      : "PageController/CurrencyController.php",
    data     : formData,
    dataType : "text",        
    async    : false,
    success  : function(html, textStatus, xhr) {
        alert(" ajax done"+html);
        if ( html != '' ) {
            output = html;
        }
    },
    error    : function(xhr, textStatus, errorThrown) {
         alert("Req "+xhr+" status "+textStatus+"  Error "+errorThrown);
    }
});

More about XMLHttpRequest 有关XMLHttpRequest的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM