AJAX segments?

Since the data am transmitting is exactly the same I am trying to ‘piggyback’ an AJAX request so that the resulting text can be split between two separate elements. I have done this before but it’s been a stressful week and am drawing a blank.

Essentially the processing document returns this text:

“<DIV id=‘area1’> … HTML for area 1 </DIV>
<DIV id=‘area2’> … HTML for area 2 </DIV>”

I thought there was a way got get the AJAX call to return each ID’ed element as a SEPARATE ELEMENT but IN THE SAME CALL, if that makes sense

Hi,
Try get the returned value with the two segments in JSON format:

{"area1": "HTML for area 1",
"area2": "HTML for area 2"}

Transform the JSON string in object, for example with:

var myObject = JSON.parse(JSONstring);

Then, get each element and add it into <div> .

ah makes sense!, thanks MarPlo!

I think what I was remembering involved jQuery, which I guess parses the HTML response… but as I normally try to avoid libraries when I can, this would be a great way of doing the same.

I was also going to try a text split. The problem , of course would have been that I would have to make a ridiculously unusual delimiter , as I am dealing with nested code.