What's the best way to send JavaScript array to PHP script using GET?

前端 未结 6 646
轮回少年
轮回少年 2021-01-22 13:34

I have an interactive web application powered by jQuery where users can manipulate visual objects on the screen. When done, the \"state\" of JavaScript objects should be sent to

6条回答
  •  鱼传尺愫
    2021-01-22 13:50

    json_decode() should serve you well here.

    If you simply append a string containing the JSON representation of your javascript object to your HTTP request, you can json_decode() it in PHP and have a PHP object ready to go.

    Edit: I should mention that this page has a link to a Javascript JSON stringifier, which will convert your JS objects into the necessary JSON.

提交回复
热议问题