Javascript 我的代码在某些更改后停止工作

Javascript 我的代码在某些更改后停止工作,javascript,codeigniter,Javascript,Codeigniter,在xhr.send(data)成功后,我试图重新加载页面 但我认为这失败了 var xhr = new XMLHttpRequest(); xhr.open('POST', "User/adde", true); xhr.onload = function(){ if (xhr.status==403 || xhr.status==404) { alert("ERROR LOADING 3-UPLOAD.PHP");

在xhr.send(data)成功后,我试图重新加载页面

但我认为这失败了

    var xhr = new XMLHttpRequest();
    xhr.open('POST', "User/adde", true);
    xhr.onload = function(){
        if (xhr.status==403 || xhr.status==404) {

           alert("ERROR LOADING 3-UPLOAD.PHP");
         } else {
           //alert(this.response);
         }
    };

    xhr.send(data); // the data will send from here.

    success: function(data){
      if(data.success == true){ // if true (1)

        setTimeout(function(){// wait for 5 secs(2)

           location.reload(); // then reload the page.(3)

        }, 5000); 
      }
   }

您可以查看以下文档: