Passing data from php to Jquery

前端 未结 6 2368
北恋
北恋 2020-12-21 19:44

I have all my javascript/jquery code in a file and include it into my page. Without having apache process js files as php what would be the best way to pass data from php to

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 20:19

    Best practice is likely as Matt mentions in the comment above: use JSON. If you're going to use jQuery, you can have a PHP script you call using either $.get() or $.getJSON(). You can find the manual for PHP JSON here: http://php.net/manual/en/book.json.php, and the API reference for the jQuery method $.getJSON() here: http://api.jquery.com/jQuery.getJSON/

    HTH.

提交回复
热议问题