Passing variables between two ajax calls in PHP -
i'm creating personal website task management in project environment.
i've got mysql table (tblprojects) contains following fields; id, ownerid, projectname , createddate. i've got table (tbltodos) contains following fields; id, projectid (links id in tblprojects) todoname, tododuedate, createddate.
the idea being many todos can belong project.
at present, when site loads, i'm using ajax , jquery show list of projects. when click on 1 of projects in list, want able run ajax query load todos project separate div on same page (similar when click on email in gmail example, email content loads on right)
the crux of problem don't know how pass id of project first ajax request second 1 can return todos associated project clicked on.
you associate each project id, i.e., got button each project:
<input type="button" value="show todos project" onclick="showtodos(1)">
where "1" id of project.
then, in showtodos()
function, have this:
function showtodos(projectid) { $.ajax({ type: "get", url: "/todos.php?id=" + projectid, success: function (json) { // construct div here } }); }
Comments
Post a Comment