Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2011, 08:09 PM   PM User | #1
[vengeance]
Regular Coder

 
Join Date: Aug 2009
Posts: 131
Thanks: 28
Thanked 7 Times in 7 Posts
[vengeance] is an unknown quantity at this point
Image click -> load() not working

Hello.

How come this won't work? I thought it was simple as this, but when I click on an image it won't update the contents of another div box...

Code:
$(function(){       
    $('#pdrNavWrapper img').click(function(){
        var pageFile = $(this).attr('id');
        
        $('#pdrPageWrapper').load('pages/' + pageFile + '.php');
    });
});
What am I doing wrong?
[vengeance] is offline   Reply With Quote
Old 02-21-2011, 08:31 PM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
Whether this works or not depends on your CSS selectors being right, and on the AJAX request returning without error, and there's no way for us to know what exactly failed. The easiest way to find out would be to give us the URL to the page where you tried to implement that code.

But you're right, given you've done everything else correctly, it's as simple as that.
venegal is offline   Reply With Quote
Old 02-21-2011, 08:39 PM   PM User | #3
[vengeance]
Regular Coder

 
Join Date: Aug 2009
Posts: 131
Thanks: 28
Thanked 7 Times in 7 Posts
[vengeance] is an unknown quantity at this point
Hi,

Thanks for your reply. I've sent the link through PM.

The load function should work when clicking the navigation buttons on the left sidepanel - but they don't. And Firebug doesn't report anything.
[vengeance] is offline   Reply With Quote
Old 02-21-2011, 09:05 PM   PM User | #4
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
The buttons work absolutely fine for me. After clicking, the white box in the middle shows the title of the button, which is what the server returns.

Please describe what exactly is happening for you, what browser (version) you are using, and whether the AJAX request comes back with status "200 OK" (your debugger can tell you that).
venegal is offline   Reply With Quote
Old 02-21-2011, 09:13 PM   PM User | #5
[vengeance]
Regular Coder

 
Join Date: Aug 2009
Posts: 131
Thanks: 28
Thanked 7 Times in 7 Posts
[vengeance] is an unknown quantity at this point
That's odd.

Because mine doesn't do anything at all. When I click it, absolutely nothing happens. I tried with both FireFox and Google Chrome, both up to date.

And no, Firebug doesn't return anything at all - it's like no actions were made.
[vengeance] is offline   Reply With Quote
Old 02-21-2011, 09:36 PM   PM User | #6
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
Well for me it works in all browsers. If for you it doesn't, you have some debugging to do:

Is the DOM ready handler getting called at all?
If so, do those '#pdrNavWrapper img' elements exist ($('#pdrNavWrapper img').length)?
If so, does the click handler get called?
If so, is the AJAX call going out?
If so, is it coming back?
If so, without error?
If so, is the response being put into that div?
If so, is it visible?
If so, you see it, and you're finished.

That's nothing I can help you with, because I can't reproduce the issue.
venegal is offline   Reply With Quote
Old 02-22-2011, 10:58 AM   PM User | #7
[vengeance]
Regular Coder

 
Join Date: Aug 2009
Posts: 131
Thanks: 28
Thanked 7 Times in 7 Posts
[vengeance] is an unknown quantity at this point
Thanks.

But I found out why, it's not working.

Apparently, it didn't want to do the load when I didn't have www. in the URL - why it won't, I don't know - maybe you could tell me.

So I just made .htaccess force www. on the URL, and it works now.
[vengeance] is offline   Reply With Quote
Old 02-22-2011, 03:46 PM   PM User | #8
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
Since you already changed it, I can't have a look why it didn't work. But I'm no magician either, so in order to find out why, I'd do exactly what I told you to do in my last post.

So, if you're really interested in the reason, please revert the change, so I can tell you, or debug it yourself.
venegal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:08 PM.


Advertisement
Log in to turn off these ads.