【发布时间】:2014-11-18 09:39:05
【问题描述】:
我正在尝试使用 json.stringify 发布数据
像这样的数据
<script>
$('.create-invoice').on('click', function()
{
grab_invoice_data();
// Declare a variable
var jsonObj = invoice_data;
// Lets convert our JSON object
var postData = JSON.stringify(jsonObj);
// Lets put our stringified json into a variable for posting
var postArray = {json: postData};
$.download("json.php", postArray, 'post');`enter code here`
})
</script>
// php has like this
<?php
$arrData = json_decode($_POST['json'],true);
extract($arrData , EXTR_PREFIX_SAME, "wddx");
$firstName = $arrData['name'];
$address1 = $arrData['address1'];
$address2 = $arrData['address2'];
$city = $arrData['city'];
$state = $arrData['state'];
echo $firstName;
echo $address1;
echo $address2;
?>
注意:未定义索引:第 7 行 C:\xampp\htdocs\ASK_Soft\json.php 中的名称
注意:未定义索引:第 8 行 C:\xampp\htdocs\ASK_Soft\json.php 中的地址1
注意:未定义索引:第 9 行 C:\xampp\htdocs\ASK_Soft\json.php 中的地址 2
注意:未定义索引:第 10 行 C:\xampp\htdocs\ASK_Soft\json.php 中的城市 . . 谢谢。
【问题讨论】: