Binary101010
Binary101010

Reputation: 580

This Ajax javascript code not working right

So I have been busy building a site for a customer. Now I need to do some ajax on menu clicks. The code below is successful in showing the loading.gif and not 100% sure it does the ajax as the dang page still loads up regular style with the gif spinning. Works but doesn't..

Anyways heres a link to it: and login is username: password:

Click on "Friends" Link to see the spinner and the code below is viewable via firebug. Any help here is good help, this is actually my first time messing with ajax.

Thanks, Nick

<script type="text/javascript">

$(function() {
$(".item-206").click(function() {
    $("#dvloader").show();
    $.load("friends", function(){ $("#dvloader").hide(); });
    return false;
});
});
</script>

Upvotes: 0

Views: 78

Answers (2)

dave
dave

Reputation: 64657

You have to tell it where to load the html into:

$('#div-you-want-to-populate').load("friends", function() { ... });

If you make an array of div ids, and name them the same as the target divs, you can do:

var ids = ['id1', 'id2','id3']; 
for (i=0; i<ids.length, i++) { 
    $('#'+ids[i]).load("friends #"+ids[i], function() { ... });
};

Upvotes: 2

Tamil Selvan C
Tamil Selvan C

Reputation: 20199

use

$('element or id or class').load("friends", function(){ $("#dvloader").hide(); });

Upvotes: 1

Related Questions