1
使用API我正在使用Javascript創建論壇。更改URL字符串中的數據 - 使用API進行數據庫請求
當用戶點擊index.html
頁面上的主題標題,他們被帶到一個叫就到這裏thread.html
頁我使用的API調用,以顯示與ID爲線索,結果1
var threadRequest = new Request.JSON({
url: 'control.php?action=getThread&id=1',
onSuccess: threadSuccess
}).send();
我問題是,我將如何改變這種做法,它知道哪些線程已被點擊,所以它知道哪個線程調用,我已經試過
function callThread(thread){
var threadRequest = new Request.JSON({
url: 'control.php?action=getThread&id='+thread,
onSuccess: threadSuccess
}).send();
}
與thread
是在鏈接到API表的外鍵。
線程標題顯示,像這樣
var jsonRequest = new Request.JSON({
url: 'control.php?action=getThreadList',
onSuccess: ajaxSuccess
}).send();
這是threadSuccess功能以及
function threadSuccess (jArray){
jArray.each(function(post){
var postObject = new PostItem(post.id, post.name, post.comment, post.thread);
postObject.display().inject($('postList'));
})
}
我的問題是你得到它,這樣的URL字符串會做類似url: 'control.php?action=getThread&id=what ever number thread the user has clicked on
帖子表中包含字段id,名稱,註釋,時間戳和線程(這將定義帖子將在哪個線程中)。
和一個線程表包含ID和標題。
這裏有個問題嗎?當你說你嘗試過時,它不起作用嗎?什麼不起作用?似乎是合理和直接的 - 忽略了「爲什麼」以及你從服務器公開的內容,seo等等。你可以做的一件事是將URL設置爲'control.php',方法爲'get'並將對象作爲'data'傳遞給key-> value對,更容易管理 – 2013-05-05 20:49:34
我的問題是我需要做什麼,它做了類似'url:'control.php?action = getThread&id =用戶點擊過的任何數字線程'換句話說如果用戶點擊線程號5,則會在等號後添加一個5。 – joshuahornby10 2013-05-05 21:55:52
沒有錯誤時,它不工作屏幕只是空白,換句話說查詢失敗。 – joshuahornby10 2013-05-06 08:56:27