Sending HTML Code Through JSON

前端 未结 7 1092
暗喜
暗喜 2020-11-30 07:07

I\'ve got a php script which generates HTML content. Is there a way to send back that HTML content through JSON to my webpage from the php script?

7条回答
  •  一向
    一向 (楼主)
    2020-11-30 08:03

    All string data must be UTF-8 encoded.

    $out = array(
       'render' => utf8_encode($renderOutput), 
       'text' => utf8_encode($textOutput)
    );
    
    $out = json_encode($out);
    die($out);
    

提交回复
热议问题