json_encode not working with a html string as value

前端 未结 8 1680
太阳男子
太阳男子 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:28

    If you cannot find a better solution for this you can encode the value to base64 encoding:

    $data = array('upload_data' => $this->upload->data());
    $str = base64_encode("
    Nachricht empfangen!
    "); echo json_encode(array('file_name' => $data['upload_data']['file_name'], 'prompt' => $str));

    and in the client decode it, IMO this is more safer this is also more applicable if you're processing characters from different languages.

    ALSO:

    to sure that no other characters will be added on the json string call exit; writer after you print it.

提交回复
热议问题