【发布时间】:2015-08-27 02:51:47
【问题描述】:
我在文件 update_customer.php 中有代码 PHP 来保存客户信息
<?php
date_default_timezone_set('Asia/Ho_Chi_Minh');
$response = array( 'status' => 0, 'message' => '', 'typeinsurance' => '', 'thoigianmua' => 0 );
if (empty($_GET) && !empty($_POST) && count($_POST) == 7 && isset($_POST['fullname']) && isset($_POST['email']) &&
isset($_POST['address']) && isset($_POST['phone']) && isset($_POST['cost']) && isset($_POST['typeinsurance']) &&
isset($_POST['typepay']))
{
require_once ('./../include/database.php');
$database = new Database();
$time = time();
$_POST['thoigianmua'] = $time;
if ($database->insert('customer', $_POST)){
$response['status'] = 1;
$response['typeinsurance'] = $_POST['typeinsurance'];
$response['thoigianmua'] = $time;
}
}
echo json_encode($response);
并编码 JQUERY 以发送数据,但我的 JSON 得到
Object {status: 1, message: "", typeinsurance: "<?php echo $_POST['typeinsurance']; ?>", thoigianmua: 1440642246}
请帮助我,在此先感谢
【问题讨论】:
-
向我们展示生成此输出的 PHP 代码。
-
您能否展示一个您期望的 JSON 样本以及应该生成它的字段的输入?
-
这是我的 PHP 代码
$response['status'] = 1; $response['typeinsurance'] = $_POST['typeinsurance']; $response['thoigianmua'] = $time; -
据我所知,您似乎正在通过帖子字段
typeinsurance发送实际字符串<?php echo $_POST['typeinsurance']; ?>,但我发现很难将您的代码与输出相关联 - 您能否发布更多实际的代码生成响应和发送请求的代码? -
我要显示 JSON
Object {status: 1, message: "", typeinsurance: "xehaibanh", thoigianmua: 1440642246