2011-04-10 56 views
0

我使用AJAX從我的php頁面動態獲取數據並將其顯示在html頁面上。它不工作。這裏是link to the pageAJAX動態獲取文件中的數據不起作用

HTML Page where the call is made and result should be displayed 
    <h3><a href="#" id="get">John</a></h3> 
    <div> 
     <p class="post">Result to be displayed</p> 
    </div> 

AJAX代碼

$.ajaxSetup ({ 
     cache: false 
    }); 

    // load() functions 

    var loadUrl = "../load.php"; 
     $("#get").click(function(){ 
     $(".post") 
      .html(ajax_load) 
      .load(loadUrl, "language=php&version=5"); 
    }); 

回答

2
$(function(){ 
    $.ajaxSetup ({ 
     cache: false 
    }); 

var loadUrl = "../load.php"; 
     $("#get").click(function(){ 
      $(".post") 
       .html(ajax_load) 
       .load(loadUrl, "language=php&version=5"); 
     }); 
}); 

是相當多的,你想要什麼。

+0

感謝您指出,但仍然不工作 – dragonfly 2011-04-10 08:56:06

+0

@dragonfly發現你的下一個問題,你是在jQuery之前引用你自己的JavaScript。下次首次使用firebug/webkit開發工具進行測試。 – 2011-04-10 08:58:00

+0

它也應該在$(function(){codehere})塊中; – 2011-04-10 09:05:13