我有一个ajax页面,它将包含表单功能和动态html代码。请检查下面的例子必须jsonencode的结果,但表单是动态格式不能得到它的工作。
//getting_result.php
require_once('include/form.class.php');
$rowid = $_POST['rowid']; // database row id to retrieve the content
$getjson_form = getJsonForm($rowid); // will get the jsonform name
$form = new Form(['file'=>$getjson_form[0]['json_form_name']]);
// will show the form
ouput <div class="form-row" id="form_output_row"><div class="form-group col-md-6">//
$pagecontents = file_get_contents("llor.html");
$get_form = $form->show();
$total_output = array("json_form_name"=>$get_form);
echo json_encode($total_output,JSON_FORCE_OBJECT);
mypage for ajax jquery
$.ajax({
type: "POST",
url : "getting_result.php",
data : {rowid:id },
dataType: "json",
cache: false,
success: function(data){
console.log(data.json_form_name);
//$("#jsonformname").html(data.json_form_name);
var find_form = $(data).filter('#form_output_row');
console.log(find_form);
$("#jsonformname").html(data.json_form_name);
// $("#terms_cond").html(data.terms_condi);
}
});
您可以使用:
JSON.stringify(data);