D
dan.goyette
I'm fairly new to using AJAX. I'm currently developing a data grid
application in coldfusion, using AJAX for paging/filter/sorting
updates to the grid. So far I've just been returning raw html, and
updating the innerHTML of a div on the page when the response comes
back.
But now I've decided it would be useful to split my response into (at
least) two parts. The first will be the raw HTML to place in the div.
The second part will be separate data that will run through a
javascript function to update some values on the page. The details
aren't too important, but the idea is that instead of a single block
of text, I'd like to be able to send two distinct blocks with the ajax
response.
In playing around with JSON a bit, I've got it working for a simple
structure like this:
{html:"some html",
javascript:"some javascript to execute"
}
I can reference those after evaling the response, and use the text.
The problem comes when I actually place myt HTML into the JSON object.
It's kind of a lot of HTML, and something seems to be breaking in the
response. It seems to be hanging during the eval process on the
response, though I can't see why.
Is it a horrible idea to try to pass html within a JSON object? Is
there a way to encode or escape the text beforehand so that it can be
passed properly?
Thanks.
application in coldfusion, using AJAX for paging/filter/sorting
updates to the grid. So far I've just been returning raw html, and
updating the innerHTML of a div on the page when the response comes
back.
But now I've decided it would be useful to split my response into (at
least) two parts. The first will be the raw HTML to place in the div.
The second part will be separate data that will run through a
javascript function to update some values on the page. The details
aren't too important, but the idea is that instead of a single block
of text, I'd like to be able to send two distinct blocks with the ajax
response.
In playing around with JSON a bit, I've got it working for a simple
structure like this:
{html:"some html",
javascript:"some javascript to execute"
}
I can reference those after evaling the response, and use the text.
The problem comes when I actually place myt HTML into the JSON object.
It's kind of a lot of HTML, and something seems to be breaking in the
response. It seems to be hanging during the eval process on the
response, though I can't see why.
Is it a horrible idea to try to pass html within a JSON object? Is
there a way to encode or escape the text beforehand so that it can be
passed properly?
Thanks.