Ajax request returns nothing. why?

前端 未结 3 2001
无人共我
无人共我 2021-01-24 12:14

Below is the ajax request.

$.post(\'delete.php\', {\'deletearray\':deletearray, \'dir\':dir}, function(deleted, undeleted){
    if(undeleted == 0) {
        aler         


        
3条回答
  •  醉酒成梦
    2021-01-24 12:56

    First thing-

    Use $_POST['deletearray'] instead of $_POST[deletearray]

    Second thing-

    You cannot return different variables from the PHP scrtipt, every thing you print there is returned in the ajax callback, so just write this-

    PHP

    json_encode(array('totalDeleted' => $deleted, 'totalUndeleted' => $undeleted));
    

    AJAX

    ...
    function(response){
         response=JSON.parse(response);
         console.log(response);
    }
    

提交回复
热议问题