JavaScript向php传递json数据之后php解析json数据

通常从json向php传递数据之后需要对其进行解析

发送之前的数据

var jsonMsg =[{"wellname":"信1","startdate":"20150901","enddate":"20150930"}];  
	jsonMsg[0]['wellname'] = wellname;
	jsonMsg[0]['startdate'] = startdate;
	jsonMsg[0]['enddate'] = enddate;
  
    var json_string = JSON.stringify(jsonMsg); 		
    alert (json_string);  
    document.getElementById("jsoninfo").value = json_string;	


php解析json数据方法如下

    $data = $_REQUEST['jsoninfo'];
    $json_string = json_decode($data);
    echo ($json_string[0]->startdate);


你可能感兴趣的:(JavaScript向php传递json数据之后php解析json数据)