Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts

    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?

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    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.

  • #4
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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).

  • #5
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    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.

  • #6
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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.

  • #7
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    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.

  • #8
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •