我有一个表格必须填写来自JSON数据的数据,表格应该使用mpdf创建为pdf并发送到mail.for我使用的是jquery和ajax。
首先,我使用了将json数据发送到PHP文件的ajax。在PHP文件中,我使用的是以下
`$json = file_get_contents('php://input');//to getting json post values we need to use
$obj = json_decode($json,true);
$obj1=http_build_query($obj);
//print_r($obj);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $obj1
)
);
$context = stream_context_create($opts);
$result = file_get_contents('PDF_Form.php', false, $context);
echo $result;`
结果现在显示而不是值。请告诉我问题在哪里。
我需要将所有帖子值放在表单中,然后将表单转换为字符串转换为ajax响应以创建pdf和发送邮件。
的问候, 雷卡
答案 0 :(得分:1)
我自己找到了解决这个问题的方法。
$json = file_get_contents('php://input');//to getting json post values we need to use
$obj = json_decode($json,true);
ob_start();
include('PDF_Form.php');
$template_html = ob_get_contents();
ob_end_clean();
echo $template_html;
在我使用的PDF_Form.php文件中......
<html>
<head></head>
<input type="text" name="eg" value="
<?php echo $obj['status'];?>
">
</html>
它完美无缺......
此致
雷卡