Front-end string js object array for php framework thinkphp

Source: Internet
Author: User
Front-end string js object array for php framework thinkphp
// Js Object "script" person [] = new Object (); person [0]. firstname = "Bill"; person [0]. lastname = "Gates"; person [1]. firstname = "Bill"; person [1]. lastname = "Gates"; // Convert the object into a json string var jsonstr = JSON. stringify (person); // pass to php $. post ('URL', {obj: jsonstr}, function (data) {}, 'json'); script // php code public function get_json () {// Obtain the json string // note that it is best not to use the I method provided by the framework to obtain data using the thinkphp framework, because the I method will escape double quotation marks inside the string while filtering the string, result in json parsing failure and return null. If you use the json_last_error () function to obtain the returned message, the returned value may be 4, indicating a syntax error. $ Str = $ _ POST ['obj ']; // parse json $ str = json_decode ($ str );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.