Sunday, 26 May 2013

Passing a varible from jQuery to PHP

Passing a varible from jQuery to PHP

I have a a bunch of li's that are a blog but i want to show them enlarged in a colorbox. Therefore I need to know which li I clicked so I can get that ID and use that in my query to get all the date for that post.
Now I thought that the best way is to retrieve the blog id with jQuery and then use that to add to my query in the footer.
    <li id="<?php the_ID;?>">blog</li>
    <li id="<?php the_ID;?>">blog</li>
    <li id="<?php the_ID;?>">blog</li>
    <li id="<?php the_ID;?>">blog</li>

    //My colorbox inline frame
    <?php query_posts( 'p="the_ID_of_clicked_li' ); ?>
     etc etc
I think this can be done with AJAX but is there a more simple method and give me a clean URL?
I haven't AJAX in projects before, so I am a beginner with that.
Any thoughts would be appreciated

No comments:

Post a Comment