0

[json['information']こんにちは、コードを実際の変換された html コードとして出力したいと思います。

現時点では、文字列全体を純粋なテキストとして出力しているようです(フォーマットされていないhtmlなので、すべてのタグなどを見ることができます)json。 .

前もって感謝します

$('.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));
            }

            }
4

2 に答える 2

0

PHPコントローラーにOpen cartを使用しているようです。適切な json ヘッダーを使用して応答を返すには、カートを開く方法は次のとおりです。

$this->load->library('json');
$this->response->setOutput(Json::encode($json));

それが役立つことを願っています。

于 2013-04-15T22:24:20.230 に答える