0

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 ?

3 Answers 3

3

You may use an Object as the data attribute

//...
   data: {
       page: page,
       rev: rev
   },
//...
Sign up to request clarification or add additional context in comments.

Comments

1

You need an object:

data: {page: page, rev: rev},

Though you might want to rename your variables so that you won't be confused.

Comments

0

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.
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.