Simple Ajax with YUI!!!

For those of you, who want to get started with YUI and Ajax, this would surely prove helpful.

<title>Lets learn YUI</title>


<div id="mydiv">

Add some Text or Images if you want to replace dynamically</div>
<a href="Loading.html" onclick="return YUI();">My first AJAX</a>
<script src="build/yahoo/yahoo-min.js" type="text/javascript"></script>

<script src="build/event/event-min.js" type="text/javascript"></script>

<script src="build/connection/connection-min.js" type="text/javascript"></script>

<script type="text/javascript">


function YUI(){

var loadUrl = "Loading.html";

var callback = {

success: function(o) {

document.getElementById('mydiv').innerHTML =  o.responseText;


failure: function(o) {

alert("AJAX doesn't work"); //FAILURE



var transaction = YAHOO.util.Connect.asyncRequest('GET', loadUrl, callback, null);

return false;






This is how one can simply make AJAX calls using YUI. The code is simple and self explanatory. If you need any help with this, please drop in comments.


If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored.

The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations.

CHECK out and BUY the PHP and book at Packt official site


Tags: , , , ,

About srinix

I am Sridhar, a matured nut, on this planet with water, air and love ;)

9 responses to “Simple Ajax with YUI!!!”

  1. Juan Felipe says :

    Hola estoy realizando mi sitio con las librerias de yahoo YUI, pero no logro enviar parámetros usando AJAX o JSON, podrían darme la solucion?, gracias.

  2. HARSh says :

    hiii i wanna learn YUI i konw c,c++ and java !! can i learn YUI or i have to learn some other languages also !!

  3. HARSh says :

    hiii i wanna learn YUI i konw c,c++ and java !! can i learn YUI or i have to learn some other languages also !!!! reply ASAP

  4. vaibhav says :

    What would be the default value for a Ajax call to get timed out in case of YUI.

  5. concern-netto says :

    u need to top-up money before you can yui.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: