Grow your CSS skills. Land your dream job.

jquery/ajax and multipl div’s

  • # June 7, 2009 at 11:59 am

    Morning all,

    I’m trying to incorporate jquery and ajax into my site to make the content as dynamic as possible. When a user clicks on the menu I have jquery/ajax updating the page content. I have images located in the div on the right that match the content, however when I put in the jquery the images stays the same when you go from Home to About Us. What is the best solution to accomplish updating both div’s upon different menu selections? Thanks in advance! You can view this at http://dev.howsmykiddriving.org.

    Thanks,

    Tim

    Rob
    # June 7, 2009 at 5:16 pm

    hey :)

    well currently you are only making the change while targeting the #content – now you need to do the same for the extra :) – but do it within the same click function, then it will trigger when you click… :)

    # June 7, 2009 at 7:28 pm

    Thanks Rob!! It work perfect! For anyone else that’s learning jquery this is what I did. Thanks again Rob!

    <script type="text/javascript">
    $(function(){
    $(‘li a’).click(function(){
    id=$(this).attr(‘id’);
    $("#content").load("pages.php?o="+id+"");
    return false;
    });
    $(‘li a’).click(function(){
    id=$(this).attr(‘id’);
    $("#extra").load("images.php?o="+id+"");
    return false;
    });
    });

    # June 12, 2009 at 6:35 am
    Code:

    why not just do both ajax calls at the same time rather than making javascript search and find the 'li a' twice and asigning the values (ect....)

    like so

    Code:
    # October 13, 2009 at 8:52 pm

    Ok, this really should not be that difficult but I am trying to use this code in order to display two (more once I figure this out) .txt files stored on my server. Someone please help me I think I might just shoot myself…every time I click either it just displays the filmone.txt. I know there has got to be something simple I am missing.

    Code:

    THANKS!!!

    Rob
    # October 14, 2009 at 4:57 pm

    Hey no probs – glad I helped it click… Jquery is great :)

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".