Reputation: 522
i have a pagination script which working with jquery and php scripts, i am trying here to pass a url variable called rev
in my url which give the pagination server side file a sql id parameter
here is my jquery code:
function loadData(page){
loading_show();
$.ajax
({
type: "POST",
url: "commentPagination.php",
data: "page="+page,
success: function(msg)
{
i tried the following but it did not work
function loadData(page){
loading_show();
$.ajax
({
type: "POST",
url: "commentPagination.php",
data: "page="+page+"&rev="+rev,
success: function(msg)
{
which it did not work , how can i get the variable from the URL then pass it through the jquery to my server side file ?
Upvotes: 0
Views: 198
Reputation: 2760
Well, Here is the complete code you are looking for:
$.ajax({
type: "POST",
url: "get-cities-xml/"+area,
data: "eid=0",
dataType: "xml",
success: function(data) {
$html = "";
$(data).find("city-name").each(function(){
$html += "<li><a class='aclick' href='getproperty/"+$(this).find("name").text()+"'>"+$(this).find("name").text()+"</a></li>";
});
$("#show-cities").html("<ul>"+$html+"</ul>");
},
error:function(xhr,err){
//alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
}
});
Now for your thing:
$.ajax
({
type: "POST",
url: "commentPagination.php",
data: "page="+page,
success: function(msg)
{
alert(msg)// that msg contains ur html response.
},
Upvotes: 0
Reputation: 634
You may use an Object as the data attribute
//...
data: {
page: page,
rev: rev
},
//...
Upvotes: 3
Reputation: 175098
You need an object:
data: {page: page, rev: rev},
Though you might want to rename your variables so that you won't be confused.
Upvotes: 1