<code>var xx = 'dfdf'; var yy = 'kfdl'; var zz = 'ijklk'; instance:[{"instance_name":xx,"machine_belong":yy,"access_port":zz},{"instance_name":xx,"machine_belong":yy,"access_port":zz}] </code>
How to handle php background
instance = [{"instance_name":1,"machine_belong":2,"access_port":3},{"instance_name":1,"machine_belong":2,"access_port":3}];
I did a test with this, and it turned out that the json was written incorrectly. The json in my code was spliced, and there was an error in the splicing
<code>var xx = 'dfdf'; var yy = 'kfdl'; var zz = 'ijklk'; instance:[{"instance_name":xx,"machine_belong":yy,"access_port":zz},{"instance_name":xx,"machine_belong":yy,"access_port":zz}] </code>
How to handle php background
instance = [{"instance_name":1,"machine_belong":2,"access_port":3},{"instance_name":1,"machine_belong":2,"access_port":3}];
I did a test with this, and it turned out that the json was written incorrectly. The json in my code was spliced, and there was an error in the splicing
<code>instance = [{"instance_name":xx,"machine_belong":yy,"access_port":zz},{"instance_name":xx,"machine_belong":yy,"access_port":zz}] // 对instance json序列化, 才可以进行数据传输 instance = JSON.stringify(instance);</code>
PHP analysis:
<code>$instance = json_decode($_REQUEST['instance'], true);</code>
No thanks
You should convert the object into a string first and then send it to the background
See your code, is js sent to the php interface?
If so, when using post, PHP can use $res=$_post['data']
If your calling interface is ajax({data:{...}});
Next, get PHP Object, similar to res.name
https://github.com/yiisoft/yi...
Please refer to this code
http://json.cn/ Test json format