我在HTML
和twitter-bootstrap library
的头部添加了ajax库,试图加载没有任何触发从PHP的数据,但PHP的工作正常,我尝试打开data.php它使输出没有控制台中的错误,但我真的不知道为什么它不起作用似乎是什么问题?jQuery AJAX分页不工作
HTML是
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
<th>address</th>
</tr>
</thead>
<tbody id = "user_data">
</table>
jQuery的是
$(document).ready(function(){
function load_data(page)
{
$.ajax({
url:"data.php",
method:"POST",
data:{page:page},
success:function(data){
$('#user_data').html(data);
alert('Successfully called');
},
error:function(exception){alert('Exeption:'+exception);}
})
}
load_data(1);
$(document).on('click', '.pagination_link', function(){
var page = $(this).attr("id");
load_data(page);
});
});
无需添加PHP及其工作罚款就输出什么,我需要这只是感谢的问题!
修订
我试图使用这些警报,这并不警报什么? The Response from Network Tab
在cosole错误的行refferring是$('#user_data').html(data);
也在网络上没有data.php –
您的load_data函数需要一个页码作为参数..当您第一次调用它时,您没有传递页面参数.. –
我将如何去传递页面参数?它是从PHP? –