Using ajax to call php and return multiple variables?

后端 未结 5 840
既然无缘
既然无缘 2021-02-04 22:30

I am trying to use javascript to call a php script which then will return multiple variables back to my javascript so I can manipulate them.

This is my JS.



        
5条回答
  •  一向
    一向 (楼主)
    2021-02-04 22:49

    Use a simply string and explode(split) it further in ajax response. Here is PHP code

    
    

    Now split(explode) the response with JavaScript

    $.ajax({ 
            url: 'test.php',
            data: { id : lastFileId },
            success: function(output) {
                 var my_arr = output.split("|");
                 console.log(my_arr[0] + "" + my_arr[1]);
            }
    });
    

提交回复
热议问题