Amol Bansode
Amol Bansode

Reputation: 365

Ajax.Request not working in Chrome

Below ajax request working in all browsers but not in chrome version 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.

Upvotes: 0

Views: 7136

Answers (1)

Daniel Gimenez
Daniel Gimenez

Reputation: 20454

Maybe the problem is using XMLHttpRequest as a function parameter name. That is a reserved word. Try changing it 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

Upvotes: 1

Related Questions