Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Thanked 0 Times in 0 Posts

    Can I use jQuery & PHP to display my project gallery?


    I have a site http://www.maestro2007.co.il/index.php?mid=3 in which i display project thumbnails on the right, by clicking it, i want that project id to open it's project photos on the left without reloading/refreshing the page. (the data/photos comes from the database using php & mysql)

    I tried doing that with ajax's XMLHttpRequest, but i can't execute javascript through responseText.

    I was told I could use jQuery for that, but i have NO CLUE has how to do so.

    Can anyone help/guide me on this one?


  • #2
    Regular Coder
    Join Date
    Feb 2009
    Wheeling, IL
    Thanked 62 Times in 60 Posts
    Most of the time when I want to replace something with a PHP reply, I use jQuery and taconite (which is a plug-in for jQuery). What you'd need to stick inside your PHP code to do the replace is:

    PHP Code:
    header('Content-type: text/xml');
        <replaceContent select=\"CSS Selector\">
            Stuff to insert.

    Pretty straightforward. Most of the time I stick a pre-generated variable in there, something like...

    PHP Code:
    $img "<img src='img1.jpg' /><img src='img2.jpg' />" 
    And well, the CSS Selector shouldn't be too hard to figure out too. Keep in mind that you need to have all tags closed and all characters that might not work well with XML fixed... otherwise it will do nothing.
    The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

    How to ask smart questions?


    Posting Permissions

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