How to pass an array of strings from PHP to Javascript using $.ajax()?

前端 未结 5 1355
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 23:11

I have a PHP script that retrieves names (strings) from database. I would like to pass this array to Javascript using $.ajax(). I cannot understand how should I encode the a

5条回答
  •  难免孤独
    2020-12-09 23:46

    This is Php File Code

    
    

    Then you can parse $array in your $.ajax() like this

    success: function (data) {
                var x = JSON.parse(data);
                console.log(x);
            }
    

提交回复
热议问题