View Full Version : Image click -> load() not working
02-21-2011, 09:09 PM
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...
var pageFile = $(this).attr('id');
$('#pdrPageWrapper').load('pages/' + pageFile + '.php');
What am I doing wrong?
02-21-2011, 09:31 PM
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.
02-21-2011, 09:39 PM
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.
02-21-2011, 10:05 PM
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).
02-21-2011, 10:13 PM
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.
02-21-2011, 10:36 PM
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.
02-22-2011, 11:58 AM
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.
02-22-2011, 04:46 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.