jquery ajax result with a wrong format

Posted by ??? on Stack Overflow See other posts from Stack Overflow or by ???
Published on 2012-04-05T11:25:54Z Indexed on 2012/04/05 11:29 UTC
Read the original article Hit count: 221

Filed under:
|
|

I am facing a problem which is the result processed by AJAX, this situation is I would like to pass the result (from AJAX) 'f f f f \'' into get_option(''), I don't know why it become like this:-

<li \'');="" f="" onclick="get_option('f" class="option normal_size">
    <a href="javascript:void(0);">f f f f \'</a>
</li>

What I want is :-

<li onclick="get_option('f f f f\'')" class="option normal_size">
    <a href="javascript:void(0);">f f f f \'</a>
</li>

I guess the problem might be the space, but I don't know how to solve it, can anyone do me a favour?

my AJAX coding is:-

.ajax({                         
    url:'inc_board_saving.php?board_title_input='+board_title_input_encode+'&cate_selected='+cate_selected_input_encode+'&cate_setting_selected='+cate_setting_selected,
    type:'GET',
    data:"nums="+Math.random()*1235,
    success: function(data){
    try{
        var content="";
        var obj =  eval('('+data+')');

        for (var i=0;i<obj.length;i++){
            content += "<li class='option normal_size' onclick=get_option('"+obj[i].board_name_encode+"');><a href='javascript:void(0);'>"+obj[i].board_name+"</a></li>";
        }

    }catch(e){
        return;
    }
    }
});

Result:-

[{"board_id":"66","board_name":"f f f f '","board_name_encode":"f f f f \'"},{"board_id":"65","board_name":"t t t t t","board_name_encode":"t t t t t"},{"board_id":"64","board_name":"yy yyy yy","board_name_encode":"yy yyy yy"}]

Thanks all

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery