嗨,我想将代码输出[json['information']
为实际转换的 html 代码。
目前,它似乎只是将整个字符串输出为纯文本(未格式化的 html,因此您可以看到所有标签等)我仍在学习,json
所以我不确定应该如何处理收到的内容以使其成为正确的 html .
提前致谢
$('.engineering-services').live('click', function() {
$.ajax({
url: 'index.php?route=information/information/homepage_info',
type: 'post',
data: {info_for : 'engineering'},
dataType: 'json',
success: function(json){
$('#engineering-content').html(json['information']);
},
error: function(json) {
alert('fail');
}
});
});
编辑,这是 PHP ...
public function homepage_info() {
$this->load->model('catalog/information');
$json = array();
if (isset($this->request->post['info_for'])) {
if ($this->request->post['info_for'] == 'engineering') {
$information_info = $this->model_catalog_information->getInformation(10);
$json['information'] = $information_info['description'];
}
$this->response->setOutput(json_encode($json));
}
}