PHP arrays into javascript arrays

前端 未结 6 527
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 01:41

I am a bit confused here on how I implement an array into JS from PHP....

I\'m doing this for testing - eventually I\'ll use long polling or websockets if they get h

6条回答
  •  一生所求
    2021-01-17 02:09

    You can use AJAX (much easier). Make your PHP script echo $data, and then using jQuery ajax request the data in your HTML file as JSON. For example:

    $.ajax({
        url: script_url,
        dataType: 'json',
        success: function(json)
        {
             ...
        }
    });
    

提交回复
热议问题