IE 9 ajax.reload() not working

IE 9 ajax.reload() not working

oldano97oldano97 Posts: 10Questions: 4Answers: 0
edited July 2015 in Free community support

I used ajax.reload() function to update my table when add or modify data, it works fine on all browsers, but not in Internet Explorer.
What should i do ?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    You should link to a test page showing the issue so we can debug it :-)

    Allan

  • oldano97oldano97 Posts: 10Questions: 4Answers: 0

    Here is my table initialization:

    var table = $('#user').DataTable( {
            pageLength: 20,
            dom: 'Tfrtip',
            ajax: {
                url: "getUsers.php",
                type: 'POST'
            },
            columns: [
                { data: "USER.USR_LASTNAME" },
                { data: "GROUP.GRP_NAME" }
            ]
          });
    

    And with this metod I post to a php page the data taken from a modal, then I call the ajax.reload() :

    $('#save').click(function(){
            var data = new Array(
                new Array("NaN", ($('#addLast').val())),
                new Array("aN", ($('#addGrp').val()))
              );
            var tb = new Array(1, "USER");
            var usr= { 
              tb: tb,
              data: data
            };
            $.post("add.php", usr);
            table.ajax.reload(null, false);
          });
    

    The php page just insert the data into a mysql db.

    The problem is that in all the browsers when I insert a new row using this functions it works fine, and after the table automaticaly reload his correct content from the db, but in Internet explorer after the ajax.reload() the table still showing the old data.

    I thought it was a problem of the IE cache, so I added this in my script:

    $.ajaxSetup({cache: false});
    

    But it still not working.

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    I would suggest doing the ajax.reload() call inside a $.post callback - regardless of what browser you are using.

    Allan

  • oldano97oldano97 Posts: 10Questions: 4Answers: 0

    Thank you a lot,
    I had already solved my problem with a setTimeout(); but your solution is more efficently, of curse. Now it works fine.

This discussion has been closed.