我想利用 AJAX 來讀取資料庫(php)更新網頁
這是我找到的範例 http://behstant.com/blog/?p=662
這是我js檔裡 ajax 的部份
function makeAjaxRequest(){
$.ajax({
url: 'search.php',
type: 'get',
data: {name:('input.detail').val()},
success: function(response){
$('table#resultTable tbody').html(response);
}
});
在php裡,我試只 echo "<tr><td colspan='4'>There were not records</td></tr>"
只有在按下button後才會執行它
但它無法更新 tbody , 檢查過 button click function 沒問題
想請教各位不知哪裡出錯了 , 還有更好的方法來讀取資料庫更新網頁(同一個頁面)嗎 ?
作者: ritchie7519 (Ritchie) 2014-02-03 13:23:00
我試把 hide() 放進 ajax , 按下按鈕後 物件會消失但是頁面會重整 , 物件又會出現了...是ajax出錯了嗎?