简体   繁体   中英

Ajax success callback only works in Chrome

Although I have read a few posts similar to this I cannot seem to get it working. I have the following Ajax that is called when a button is pressed.

   function refreshTab(){
           theObject = {
               getArray: function(callback) {

                   $.ajax({
                       url: 'urlGoeshere',
                       data: "",
                       type: "GET",
                       dataType: 'json',
                       success: function(data)         
                       {                                                          
                           callback.call(this,data);
                           alert("testing");
                       },
                       error: function (err)
                        {
                            alert(err.responseText)
                        }
                   });
               }
           }
           theObject.getArray(function(data) {
               javascript: console.log(data);
               for(i=0;i<data.length;i++){
                   auditHolder = auditHolder + "<tr class='gradeU'><br><td>" + data[i].Description + "</td><td style='width:100px' align='center'>" + data[i].CreatedOn + "</td><br></tr>"
                   // $('#container tbody').append("<tr class='gradeU'><br><td>" + data[i].Description + "</td><td style='width:100px' align='center'>" + data[i].CreatedOn + "</td><br></tr>");

               }
               $('#container tbody').html(auditHolder);

           });                                          
       }

The above code works perfectly in Chrome however does not work in either FF or IE. Currently using jQuery 1.4.4.

Through the alert("testing"); I found that the line that seems to break the code is

     callback.call(this,data);

Putting an alert box before it works in all browsers however only in Chrome does the alert box fire after the callback.

Thanks a lot for any help.

I have just now run into the same issue and found a combination of old versions of Firefox, jQuery and Firebug (!!) to be the reason for this problem. See also:

http://bugs.jquery.com/ticket/6349

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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