EasyUI Forum

General Category => General Discussion => Topic started by: sky_proj on May 07, 2016, 05:03:46 AM



Title: [Solved]- Handle submit response
Post by: sky_proj on May 07, 2016, 05:03:46 AM
i have problem with submit respone, here my code

data.php
$arr = array ('message'=>'<b>Message sent successfully.</b>',success=>true);
echo json_encode($arr);

index.php
<form id="ff" method="post">
</form>

<script type="text/javascript">
$('#ff').form('submit', {
    url:"data.php",
    success: function(data){
       console.log(data);
        var data = eval('(' + data + ')');  // change the JSON string to javascript object
        if (data.success){          
           $.messager.show({title:'Message',msg:data.message});
        }
    }
});
</script>

in console log show:
<b>Message sent successfully.&lt;\/b&gt;

I need Output in bold text:
Message sent successfully

i need help.. Thanks


Title: Re: Handle submit response
Post by: stworthy on May 07, 2016, 09:01:48 AM
You just need to call:
Code:
$.messager.show({title:'Message',msg:'<b>'+data.message+'</b>'});


Title: Re: Handle submit response
Post by: sky_proj on May 08, 2016, 09:35:52 AM
You just need to call:
Code:
$.messager.show({title:'Message',msg:'<b>'+data.message+'</b>'});

Ok - thanks


Title: Re: [Solved]- Handle submit response
Post by: arma on May 08, 2016, 11:56:54 PM
Hi Stworthy,

If i send formatted text from backend like below, how to display correctly in messager.alert ?

Code:
"Message has been sent to <span class='someclass'>someone</span> with confirmation id <b>11234</b>"

I've got it displayed as above, not a rendered html message.

Thanks.


Title: Re: [Solved]- Handle submit response
Post by: stworthy on May 09, 2016, 01:03:10 AM
You can try the following way to return the unescaped message from the server.
Code:
echo <<<SS
<textarea>
{"success":true,"message":"Message has been sent to <span class='someclass'>someone</span> with confirmation id <b>11234</b>"}
</textarea>
SS;