EasyUI Forum
May 16, 2024, 12:14:02 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [Solved]- Handle submit response  (Read 9679 times)
sky_proj
Newbie
*
Posts: 24


View Profile
« 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
« Last Edit: May 08, 2016, 09:37:38 AM by sky_proj » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 07, 2016, 09:01:48 AM »

You just need to call:
Code:
$.messager.show({title:'Message',msg:'<b>'+data.message+'</b>'});
Logged
sky_proj
Newbie
*
Posts: 24


View Profile
« Reply #2 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
Logged
arma
Full Member
***
Posts: 110


View Profile
« Reply #3 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 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;
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!