Using an API I am creating a forum using Javascript.
When a user clicks on the thread title on the index.html
page they are taken to a page called thread.html
on here I am using an API call to display the results for the thread with ID 1
var threadRequest = new Request.JSON({
url: 'control.php?action=getThread&id=1',
onSuccess: threadSuccess
}).send();
My question is how would I change this so it knows which thread has been clicked so it knows which thread to call, I have tried
function callThread(thread){
var threadRequest = new Request.JSON({
url: 'control.php?action=getThread&id='+thread,
onSuccess: threadSuccess
}).send();
}
with thread
being the foreign key in the table linked to the API.
The thread titles are displayed like so
var jsonRequest = new Request.JSON({
url: 'control.php?action=getThreadList',
onSuccess: ajaxSuccess
}).send();
This is the threadSuccess function as well
function threadSuccess (jArray){
jArray.each(function(post){
var postObject = new PostItem(post.id, post.name, post.comment, post.thread);
postObject.display().inject($('postList'));
})
}
My question is do you get it so that the url string would do something like url: 'control.php?action=getThread&id=what ever number thread the user has clicked on
The post table contains the fields id, name, comment, timestamp and thread (this will define which thread the post will be in.)
and a thread table contains id and title.
why
and what you expose from the server, seo etc. one thing you can do is set url tocontrol.php
, method toget
and pass an object asdata
with key->value pairs, easier to manage – Dimitar Christoff May 5 '13 at 20:49url: 'control.php?action=getThread&id=what ever number thread the user has clicked on'
In other words if the user clicks on thread number 5 is will add a 5 after the equals sign. – joshuahornby10 May 5 '13 at 21:55