简体   繁体   中英

empty responseText sending a xmlhttprequest

when I send the request the alert is blank. the files are uploaded fine, just no responsetext. Am I doing something wrong here?

var request = new XMLHttpRequest();

request.open('POST','upload.php');
request.setRequestHeader('Cache-Control','no-cache');
request.send(data);
alert(request.responseText);

and upload.php

if(!empty($_FILES['file'])){
foreach  ($_FILES['file']['name'] as $key => $name) {
if($_FILES['file']['error'][$key] == 0 && move_uploaded_file($_FILES['file']['tmp_name'][$key],"video/$name"))
    {
       $x = "1";
    }
        else
    {
      $x = "2";
    }
  }
}
   if ($x == "1"){echo "success";}
   if ($x == "2"){echo "failed";}

您已经处理了$x的输出,其值为1和2。如果根本没有设置$x怎么办?

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