Hmm, that's weird... i don't know why escaping/unescaping is an
issue... this is an actual working example of returned JSON from what
I am working on today:

stripped down a bit for brevity, and since Google Groups will break up
the "Data" line, it's really all one line (no line breaks like i
added)

{
     "HasError":false,
     "Mode":"Cache_List",
     "Message":"",
     "Data":"<table class=\"Cache_Table\">
           <thead>
           <tr><th>File Name</th></tr>
           </thead>
           <tbody>
           <tr><td>0111122308_Post_Attempt.xml</td></tr>
           </tbody></table>"
}

and i just simply say

$("#Results").html(response.Data);

there's no action directly needed by me to "unescape" the class name
of the table


On Jan 11, 3:41 pm, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> Sorry for the number of back to back posts...just making progress somewhat.
>
> OK! I got it part ways.... no more html after the JSON.
>
> {"data":{"title":"","year_rec":{"year":"2010"},"description":"","id":"6186d5
> 5b8f0","profile_id":"4b40eea7-2608-4a3b-9c24-7cb04adcd75b"},"status":true,"h
> tml":"<p>this is a good test<\/p>\r\n"}
>
> Now to display the HTML but without all the <\/p>\r\n
>
> Dave
>
> ________________________________
>
> From: John Arrowwood [mailto:jarro...@gmail.com]
> Sent: January-11-10 4:45 PM
> To: jquery-en@googlegroups.com
> Subject: Re: [jQuery] Re: Ajax forms help
>
> Your problem looks like it may be on the back-end.  Send the code that
> generates the JSON.
>
> On Mon, Jan 11, 2010 at 11:41 AM, Dave Maharaj :: WidePixels.com
>
> <d...@widepixels.com> wrote:
>
>         My response comes back from the server looking like this: (don't
> think its
>         right to begin with)
>
> {"data":{"title":"","year_rec":{"year":"2010"},"description":"","id":"0936d6
>
> 115e4","profile_id":"4b40eea7-2608-4a3b-9c24-7cb04adcd75b"},"status":true,"h
>         tml":"<p>this is a good test<\/p>\r\n"}<p>this is a good test</p>
>
>         But how would I display only the html section and clean it so its
> not all
>         slashed and escaped?
>
>         Thanks
>
>         Dave
>
>         -----Original Message-----
>         From: MorningZ [mailto:morni...@gmail.com]
>         Sent: January-11-10 11:44 AM
>         To: jQuery (English)
>         Subject: [jQuery] Re: Ajax forms help
>
>         "But if I am returning json I cant return my normal html"
>
>         I don't understand why...
>
>         I pretty much exclusively use JSON back and forth in my jQuery AJAX
> calls
>         and have a standard JSON object i return:
>
>         {
>           HasError: <boolean>,
>           Message: <string>.
>           Data: <object>,
>           Count: <integer>
>         }
>
>         Many times i'll return HTML on the data property there....  i think
> the
>         problem you are having is how you are creating the JSON return
> string, maybe
>         that's not the right way to do it in PHP ??  (to note, i'm a .NET
> guy, i
>         don't know what the PHP way is)
>
>         On Jan 11, 10:06 am, "Dave Maharaj :: WidePixels.com"
>         <d...@widepixels.com> wrote:
>         > Right on...looks easy enough.
>
>         > Is response.html saying to display it as html? I tried making an
> array
>         > to pass as json from php then json_encode it so my arrr was
> $response
>         > = array('status' => true , 'view' => 'all my html code went here')
>
>         > But when I returned my view data from the array it was all slahsed
> <//
>         > "// /" / / like that.
>
>         > -----Original Message-----
>         > From: Ibatex [mailto:mjgris...@gmail.com]
>         > Sent: January-11-10 4:35 AM
>         > To: jQuery (English)
>         > Subject: [jQuery] Re: Ajax forms help
>
>         > The beauty of json is that you can transfer alot of different data
> in
>         > an organized way. You can very easily send back success/failure
> status
>         > along with the html.
>
>         > success: function(response) {
>         >                         // Response was a success
>         >                         if (response.status) {
>         >                                 //update my target div
>
> $('#target_div').html(response.html);
>         >                         // Response contains errors
>         >                         } else {
>         >                                 // return the form with the errors
>
>         >                         }
>
>         > On Jan 10, 5:00 pm, "Dave Maharaj :: WidePixels.com"
>         > <d...@widepixels.com> wrote:
>         > > I need some help with a form.
>
>         > > I submit the form fine, my problem is depending on the success
> or
>         > > failure of the form being saved. I will try to explain as simple
> as
>         > > possible
>
>         > > form is in its own div <form here ..... >
>
>         > > <div target> saved data will appear here</div>
>
>         > > So what I need is i guess json success true or false response
> from
>         > > the form being saved or not then in my success
>
>         > > success: function(response) {
>         > >                         // Response was a success
>         > >                         if (response) {
>         > >                                 //update my target div
>         > >                         // Response contains errors
>         > >                         } else {
>         > >                                 // return the form with the
> errors
>
>         > >                         }
>
>         > > But if I am returning json I cant return my normal html after
> the
>         > > successful save, and if I return my response as html there is no
> way
>         > > to tell the js what to do.
>         > > The form or the target is html code
>
>         > > How can I tell what the response was (true or false) and return
> the
>         > > appropriate html code for the appropriate form or target?
>
>         > > Thanks
>
>         > > Dave
>         > No virus found in this incoming message.
>         > Checked by AVG -www.avg.com
>         > Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date:
>         > 01/10/10 16:05:00
>         No virus found in this incoming message.
>         Checked by AVG -www.avg.com
>         Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date:
> 01/11/10
>         04:05:00
>
> --
> John Arrowwood
> John (at) Irie (dash) Inc (dot) com
> John (at) Arrowwood Photography (dot) com
> John (at) Hanlons Razor (dot) com
> --http://www.irie-inc.com/http://arrowwood.blogspot.com/
>
> No virus found in this incoming message.
> Checked by AVG -www.avg.com
> Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/11/10
> 04:05:00

Reply via email to