parsa.ghaffari-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-28 17:29 UTC
evalJSON problem
Hey there,
I have a FCKeditor(a WYSIWYG online html editor) and i want to bring
it to a page by Ajax and JSON by a php request-catcher.
I have sth like this in my ajax request:
new Ajax.Request(''myactions.php'',
{
method:''get'',
parameters: {action:''bringeditor'', id:<?php echo $uid;
?>},
onSuccess: function(transport){
var response = transport.responseText;
var data = response.evalJSON();
$(''maincontent'').innerHTML=data.mytextarea;
eval(data.jsaction);*/
},
onFailure: function(){ alert(''Something went wrong...'') }
});
and in ''myactions.php'' :
$textarea= "<textarea id=''MyTextarea''
name=''MyTextarea''>
$txtareacontent</textarea>\\n";
header("Content-type: text/javascript");
$jsaction= "var oFCKeditor = new
FCKeditor(''MyTextarea'');\\n";
$jsaction.= "oFCKeditor.ReplaceTextarea();\\n";
echo "{mytextarea: $textarea, jsaction: $jsaction}";
now the problem is that i dunno what user enters in the editor, and
i''ve got problems handling characters that may conflict with the JSON
request ( like " \ \n etc) what can i do ? i tried $H ... no use. thX
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Hey there Parsa,
I''d suggest just building the textarea in the page and hiding until
the user needs it, lazy loading like that can be a big headache as im
sure you already know.
To avoid complications with forward slashes you could use the string
method, addslashes. http://us2.php.net/manual/en/function.addslashes.php
Cheers,
Matt
On Sep 28, 1:29 pm,
"parsa.ghaff...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<parsa.ghaff...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hey there,
> I have a FCKeditor(a WYSIWYG online html editor) and i want to bring
> it to a page by Ajax and JSON by a php request-catcher.
> I have sth like this in my ajax request:
>
> new Ajax.Request(''myactions.php'',
> {
> method:''get'',
> parameters: {action:''bringeditor'', id:<?php
echo $uid; ?>},
> onSuccess: function(transport){
> var response = transport.responseText;
> var data = response.evalJSON();
> $(''maincontent'').innerHTML=data.mytextarea;
> eval(data.jsaction);*/
> },
> onFailure: function(){ alert(''Something went
wrong...'') }
> });
>
> and in ''myactions.php'' :
> $textarea= "<textarea
id=''MyTextarea'' name=''MyTextarea''>
> $txtareacontent</textarea>\\n";
> header("Content-type: text/javascript");
> $jsaction= "var oFCKeditor = new
FCKeditor(''MyTextarea'');\\n";
> $jsaction.=
"oFCKeditor.ReplaceTextarea();\\n";
> echo "{mytextarea: $textarea, jsaction:
$jsaction}";
>
> now the problem is that i dunno what user enters in the editor, and
> i''ve got problems handling characters that may conflict with the
JSON
> request ( like " \ \n etc) what can i do ? i tried $H ... no use. thX
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---