json_encode not working with a html string as value

前端 未结 8 1682
太阳男子
太阳男子 2020-12-03 10:02

I am debugging this ajax for quite a time now. I have this on my jQUery file:

$(\"#typeForm\").ajaxForm({
    success : function(html){
        alert(html);
         


        
8条回答
  •  Happy的楠姐
    2020-12-03 10:21

    How about convert all the potential problem characters instead of just what fixes the problem in this circumstance:

    die(json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE));
    

    http://php.net/manual/en/function.json-encode.php

    http://php.net/manual/en/json.constants.php

提交回复
热议问题