views:

65

answers:

3

here is the code :

    $('#sousmenu a').click (function (){

    startSlideshow(<?php echo json_encode(glob("photos-" .$_GET["folder"]. "/*.jpg"));?>);
    return false;  
    });

The question is i like the HREF to change and get cautch by php, now it dont do nothing, but writing the ?folder=portraits work

here is the page

** simpler *** Maybe i am not clear.... it append sometimes !

I what the link href to be send to this PHP function

so clicking on the link animaux will send animaux to the glob() php function and will get all the .jpg file in the photos-animaux folder

clicking on the portraits will send the photo-portraits etc... etc...

+1  A: 

If you want to modify the URL and have the added/changed variable picked by PHP interpreter you have to reload your page. Just altering the URL doesn't do anything because JS is executed after PHP processing.

If your site is on http://example.com and you wish a myparam with value test to be passed to PHP you should add something like this in your JS:

document.location = 'http://example.com?myparam=test';

This will reload your page adding a new param which can be accessed in PHP by simply using $_GET['myparam'] variable.

You may also want to consider using AJAX to dynamically changing the contents of your page without having to refresh the whole page, but that's a little bit more complicated.

RaYell
tell me how to do it in AJAX, that is the way to go (i think). now the only way i used ajax, is with the $("$somediv").load("somefile.txt") to load the content of somefile in somediv
marc-andre menard
Here's the nice tutorial on how to use PHP and jQuery for simple AJAX calls: http://articles.sitepoint.com/article/ajax-jquery
RaYell
the article from sitepoint HELP a lot, thanks
marc-andre menard
A: 

Look at the source in your browser.

Php is server-side, and that means you need to use ajax or reload whole page to get a response.

There is a nice ajax part of tutorial on jquery website, after reading it you should be able to do what you want: http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery#Rate_me:_Using_Ajax

raceCh-
A: 

Cited from the comments of the topicstart:

Yep!, The problem is i capture the click on a html link (href) and do something with the post var in php. the problem is i cannot force the addres bar to change when captured ! – marc-andre menard

For that you just use window.location in JS or header('location') in php. But that would make the whole Javascript/jQuery in your click function superfluous because it creates a new request. Maybe you rather want the startSlideshow() in the $(document).ready()?

BalusC