Web Hosting Talk







View Full Version : Ajax lib - update an element with ANY html code


01globalnet
09-24-2008, 10:13 AM
Hello

do you know any ajax lib that can fill an element with any html code?

Example


<div id="container">

</div>

<a href="#" onclick="AJAX_LIBRARY_COMMAND_UPDATE('container', '/server_url.php')">update element</a>


server side script, let's say in php

<?php echo '<p>Test title</p><div>some content</div><select name="test_select"><option value=""></option></select>'; ?>



So simple, just accept raw html and update/fill a container - no need for data exchange in xml, json, no need for a special javascript function to handle the returned data.

Thank you.

Xeentech
09-24-2008, 11:22 AM
jQuery can do this.


<div id="container"></div>

<a href="/server_url.php">update element</a>



$(
function ()
{
$('#container').load('/server_url.php');

return false;
}
);


You could do it in the onclick="", but this is easier to read and maintain IMO.

Adam-AEC
09-24-2008, 11:33 AM
You could do it in the onclick="", but this is easier to read and maintain IMO.

And unobtrusive :) Definitely the best way to go.

01globalnet
09-26-2008, 11:47 AM
Thank you guys about jQuery - it seems very interesting as a js framework. I had been using www.javascripttoolbox.com libraries for common things, but now I am thinking of using a modern framework with ajax support (instead of combing different libs together).

Since scriptaculous is based on Prototype, I am also thinking of using this lib for future projects.


About the ajax thing I requested earlier, I used www.crossbrowserajax.com - it lacks documention but found the solution from their advanced example. Had some hidden tricks, no newlines etc.


Thank you.

wirefusemedia
09-26-2008, 12:23 PM
There are a few ajax tool kits. I like MooTools a lot. Take a look ;)

rapta
09-26-2008, 04:06 PM
The ajax toolkit for .NET is great, that is if you are developing in .NET :)

http://www.asp.net/ajax/ajaxcontroltoolkit/

01globalnet
10-10-2008, 02:17 PM
There are a few ajax tool kits. I like MooTools a lot. Take a look ;)

MooTools seem great! Compact, lightweight, built-in effects and seems easy.

Thank you!