私は1つのパラメータがしかしjQuery.ajax()で複数のパラメータをPHPに渡すには?
<div id="more">
<a id="<?php echo $msg_id; ?>" class="load_more" href="#">more</a>
</div>
このHTML/PHPでのAjax
$(function() {//When the Dom is ready
$('.load_more').live("click",function() {//If user clicks on hyperlink with class name = load_more
var last_msg_id = $(this).attr("id");//Get the id of this hyperlink this id indicate the row id in the database
if(last_msg_id!='end'){//if the hyperlink id is not equal to "end"
$.ajax({//Make the Ajax Request
type: "POST",
url: "index_more.php",
data: "lastmsg="+ last_msg_id,
beforeSend: function() {
$('a.load_more').html('<img src="loading.gif" />');//Loading image during the Ajax Request
},
success: function(html){//html = the server response html code
$("#more").remove();//Remove the div with id=more
$("ul#updates").append(html);//Append the html returned by the server .
}
});
}
return false;
});
});
を介して送信されたインデックス・ページ上で正常に動作し、簡単な負荷よりスタイルのスクリプトを持って、私がしたいです特定のカテゴリでも動作するように別のPHP変数を追加すると、HTMLとPHPの作成に問題はありませんが、Jqueryを初めて使用していて、追加パラメータを設定するとスクリプトを編集するのに苦労します。これはちょうどjQueryの
<div id="more"class="<?php echo $cat_id;?>">
<a id="<?php echo $msg_id;?>" class="load_more2" href="#">more</a>
</div>
は、いつものように任意のヘルプははるかに高く評価されるの編集に苦労し、私が使用して考えていますHTMLです!
追加するパラメータは何ですか? –
@ user866190 HTMLに追加のクラスタグを使用して、2番目の変数を渡す唯一の方法はありますか?あなたは3つ以上を通過する必要がある場合、あなたは何をしますか? – TimNguyenBSM