简体   繁体   中英

Ajax refreshing page without reloading doubles the content

This is the ajax code I used and I call it everytime I clicked a row in a table.

function loadPage() {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
             if (xhttp.readyState == 4 && xhttp.status == 200) {
               document.getElementById("view").innerHTML=xhttp.responseText;
              }
        };
        xhttp.open("GET", "userTable.php", true);
        xhttp.send();         
    }

the data changes whenever I clicked each row which is what I want. But the moment I clicked a row, the contents of my page (textfields, tables, button, etc) are doubled. Please help me fix this. Thanks.

I fixed it.

  $.ajax({
        type: "GET",
        url: "userTable.php?selEmp="+value,

        success: function (response) {

        $("#userBody").html(response);
        setInformation();

        }
});

this is what I used instead of the other one :)

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