0

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>
3
  • 3
    That page just gives me a 403 Forbidden error and doesn't ask for credentials. Commented Apr 16, 2013 at 2:47
  • it works just don't understand why without http or www in front of it it doesn't, ill figure that out Commented Apr 16, 2013 at 2:59
  • @Binary101010 Link fixed. It doesn't work because you likely haven't done the url rewrite rules in htaccess. Commented Apr 16, 2013 at 3:48

2 Answers 2

2

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() { ... });
};
Sign up to request clarification or add additional context in comments.

6 Comments

Ok hey thks, I actually removed that code earlier, though that was the load specific div from remote file.
I have one more question.. I guess I don't want to load the whole page, I actually just want to load specific divs into specific divs from the friends page. What Am I missing bud
edit: just realized it was dumb to put code in here, edited answer instead
give me a second I have to look at what you have on that page
Oh I mean notice when u click friends(menu item) it loads your profile into the page menu items are all the links in the navigation
|
1

use

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.