I simply explain my “problem”. I know nothing about JS and AJAX. But I’d make a simple AJAX function:
- My Menu “projects” displays the last 5 projects to which the user is involved
- When you click on one of these projects, a small drop-down list appears and you can choose “Tasks”, “presentation”, “Discussions”, etc..
- When you click on “Tasks” for example, the right part of the website is updated by displaying tasks on the project.
Not refreshing the entire page, just a div on the right.
I have to pass the ID of the project that I want to see the tasks to the right div (which simply loads tasks.php) so that it displays project tasks that I selected!
By asking a few people I was advised to pass the ID of the project by putting it in a “rel” of the div of the project, that I would recover after tasks.php, only I did not have a clue how to put it into practice, as simply as possible!
If you could help me, it would be very helpful 🙂
Seems like all you need is to build a url to your php page. Something along the lines of
tasks.php?projectId=[project id goes here]. This url would be built when the user clicked on one of the projects.For the request itself, I suggest you use jQuery’s
$.get()function (http://api.jquery.com/jQuery.get/).In PHP, you could then use $_GET[“projectId”] to retrieve the value, and act accordingly. As far as how to transfer data between the two, I’d recommend encoding your PHP response as json (using the proper content encoding, a simple set of header directives will do), obviously you’ll need to fomat the JSON to something like:
{tasks: [{id: 'task1', name: 'My task', ...}, {id: 'task2', name: 'my other task', ...}]}Does this answer your question?