Mark Rajcok wrote in an email message dated 5/24/2008 10:11 PM:
I'm writing a new CGI app, and decided to go web 2.0 -- i.e., use Ajax to update parts of the page, trying to never load an entirely new page. Thinking out loud here... with JSON, I see these advantages: - the back-end will just return data, not (HTML) document structure - I can more easily target multiple areas of the page with a single AJAX call (with jQuery, I don't think it is easy to target multiple DOM elements if I return HTML)
It is easy. Just turn the html into a jQuery object (a pseudo-Array). The ajax call should include options like these:
dataType: "html",
success: function(html){
// return from ajax is html because you specified that dataType
var $myDivs = $(html);
$('#someDiv').html( $myDivs.eq(0) );
$('#anotherDiv').replace( $myDivs.eq(1) );
//etc
}
HTH
Bruce
--
Bruce McKenzie
http://www.2MinuteExplainer.com
##### CGI::Application community mailing list ################
## ##
## To unsubscribe, or change your message delivery options, ##
## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ##
## ##
## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
## ##
################################################################
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.