View Full Version : Can I use jQuery & PHP to display my project gallery?

03-19-2009, 02:10 PM

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?


03-19-2009, 08:15 PM
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:

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

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

$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.