Using ajax to call php and return multiple variables?

后端 未结 5 841
既然无缘
既然无缘 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:58

    convert json to object

    jQuery.ajax({
        type: "GET",
        url: 'test.php',
        dataType: "json",
        success: function(response) {
           item=JSON.parse(response);
            console.log(item);
            alert(item.num1);
        }
    });
    

提交回复
热议问题