このjqueryを使用して、サーバーのphpファイルからページ分割されたデータを取得しています。php ファイルはページネーションを生成し、これらに関連付けられたデータを json 形式で返します。ページネーション データは li タグのリストとして返されます。これを使用して、html ファイル内の既存のブートストラップ ページネーションを置き換えます。
最初に、これは私のphpファイルによって生成されたものです
<ul>
<li class="active"><a>1 </a></li>
<li><a href="#2">2</a></li>
</ul>
2をクリックすると、次のページネーションが表示されます
<ul><li><a href="#1">1</a></li>
<li class="active"><a>2 </a></li></ul>
1をクリックして1のデータを取得すると、jqueryイベントが起動せず、jqueryコード
$("#pagination li a").click(function(e) {
debugger;
e.preventDefault();
var start=$(this).attr('href').split('#')[1];
var msgDiv=$('#messages');
var pagDiv=$("#pagination ul");
try{
$.ajax({ // create an AJAX call...
beforeSend: function() {showLoading(msgDiv);},
timeout:10000,
type: "post", // GET or POST
url: "./process-messages.php", // the file to call
dataType:'json',
data: {start:start}, // get the form data
success: function(response) { // on success..
if(response.status!='error'){
msgDiv.html(response.data); // update the DIV
pagDiv.html(response.page); // update the DIV
}else{
msgDiv.html(response.data); // update the DIV
}
},
error: function() { // on success..
showGeneralError(msgDiv);
}
});
}catch (e){
console.log(e);
}
});
何が問題なのですか?