json_encode not working with a html string as value

前端 未结 8 1697
太阳男子
太阳男子 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条回答
  •  囚心锁ツ
    2020-12-03 10:33

    I was having same problem with json_encode today. But after testing a lot I found the correct solution:

    In PHP to encode the array or string:

    json_encode($array, JSON_HEX_QUOT | JSON_HEX_TAG);
    

    In JS to decode the same:

    var d = $.parseJSON(content);
    

提交回复
热议问题