Re: Slashes, include, AJAX? {SOLVED}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/26/07, Rodrigo Poblanno Balp <balpo@xxxxxxx> wrote:
>
>  Nathan Nobbe wrote:
>
> On 10/26/07, Rodrigo Poblanno Balp <balpo@xxxxxxx> wrote:
> >
> > I get something like <div>this is the content<\/div>
> > it seems like the '/' is being escaped, but I need it as HTML.
> >
>
> how are you using the json object on the client-side after its sent by the
> server?
>
> below is a json snippet from an application of mine, many of the tags look
> the same
> as what youve shown (because theyve been encoded the same way).
>  ive have not encountered the problem you have, that is, the escape
> characters do
> not pass though when i splice them into the DOM.
> im using the same encoding technique i recommended within PHP.  on the
> client side
> i instantiate the json object as follows:
>
> var htmlUpdates = eval("(" + transport.responseText + ")");
>
> if you use a string directly on the client side, the escape characters
> will pass
> through, however, if you run it through eval(), the escape characters will
> be stipped
> out by the javascript interpreter.  im not sure whats going on, but im
> starting to think
> its something on the client side..
>
> -nathan
>
>  {"prevUpperNavId":"0:0","nextUpperNavId":"1:1","breadcrumb":"","leftContent":"<p>\nPHP is very interesting
>
> .  One of it's greatest strengths is the gradient of development\npossibilities.  A new PHP writer can
>
>  easily publish their first dynamic page in a matter\nof minutes.  Using PHP's integrated templating
>
>  system, PHP scripts can be escaped at any time.\nSo escaping them simply outputs anything text directly
>
>  as it appears in the script.  By adding\nscript tags into large pages of code and dropping in PHP function
>
>  calls, dynamic pages are easily\nobtained.<br\/>\n<br\/>\nAlthough handy, this isnt often the greatest
>
>  technique for developing highly reusable or readable code.\nPHP offers many options for templating HTML
>
> .  This is just the beginning.  As a PHP developer, you will\nfind yourself needing to know a lot of
>
>  technologies.\n<\/p>","rightContent":"<div>\n<p>\n\tHere is a small list of terms and acronyms one might
>
>  encounter working with PHP;\n\thow many do you recognize?\n<\/p>\n\t<ul>\n\t\t<li>\n\t\t\tObject Oriented
>
>  Programming\n\t\t<\/li>\n\t\t<li>\n\t\t\tDesign Patterns\n\t\t<\/li>\n\t\t<li>\n\t\t\tMVC\n\t\t<\/li
>
> >\n\t\t<li>\n\t\t\tORM\n\t\t<\/li>\n\t\t<li>\n\t\t\tZend\n\t\t<\/li>\n\t\t<li>\n\t\t\tCMS\n\t\t<\/li
>
> >\n\t\t<li>\n\t\t\tShared Nothing\n\t\t<\/li>\n\t\t<li>\n\t\t\tAJAX\n\t\t<\/li>\n\t\t<li>\n\t\t\tJSON
>
> \n\t\t<\/li>\n\t\t<li>\n\t\t\tUnit Test\n\t\t<\/li>\n\t\t<li>\n\t\t\tSOAP\n\t\t<\/li>\n\t<\/ul>\n<\/div
>
> >"}
>
>  Ok Nathan,
> that's correct.
>
> Once the object is decoded the \/ pairs go away. But this is something to
> note, only after it is decoded.
> I was testing only the creation of the JSON object and printing it, not
> the associative php array. So that's
> why I got the annoying \/.
>
> This is nothing to be afraid then, once the text is used, there's no need
> to think about the pairs. It is not
> even necessary to eliminate the \r\n windows puts in, that way the html
> snippet will be formated.
>

i was only thinking to strip the newlines on the server as a last resort;
the downside would
be messy html after splicing it back into the dom.  anyway, glad to hear you
got it figured out; i knew
there was something i was missing :)

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux