Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:55:37+00:00 2026-05-29T16:55:37+00:00

I have 3 file index.php, .js file, and a.php file. i made a ajax

  • 0

I have 3 file index.php, .js file, and a.php file. i made a ajax request to a.php via js(jquery) file. i am gettin response in html,(in 1 html response) there r 3 divs but i want to display one div at a time. Then click next button next div, which is in the same html response. Its a basically client side pagination via server side data(getting from 1 AJAX). But i am not able to handle 3 divs in index page one by one.

1.
the request goes –

<script>
$(document).ready(function(){
 showitem(id);
}); 
</script>
  1. simple query is processed.

    function showitem(id){

    $.ajax({    
        type    : "POST",
        cache   : true,
        //dataType: "json",
        url     : "a.php",
        data    : {
                    proid:id
                  },                
        success: function(data) {
    
            $("#match_item_display").html(data);// This is span in index.php
    
        }
    });
    

    }

3.
In the response (say) i get 9 elements in form of HTML Divs(3 in this case), i want to display 3 at a time.

$start=0; $end=6;
    for($d=0;$d<$len;$d++)
    {   
        if($end>$count)
        {
            $end = $count;
            match_pro("Closley Match", array_slice($recent_arr, $start, $end),$d);
        }
        else 
        {
            match_pro("Closley Match", array_slice($recent_arr, $start, $end),$d);
            //break;
        }
        $start=$end; $end=$end+6;
    }

Its return 3 Divs as a respone…

  1. To show – next and previous buttons.

SUMMARY -> 1-ajax request, some HTML divs as response, show them sequentially on a button click one at a time.

I am doing client side pagination because the query cannot return more than 9-12 responses at a time. so client side scripting shall be optimal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:55:46+00:00Added an answer on May 29, 2026 at 4:55 pm

    you can put the divs in an array and then return.
    eg:

    $response = array(0 => 'div1_data', 1 => 'div2_data', 2=>'div3_data');
    echo json_encode('html' => $response); // returning to ajax call
    

    in ajax call response you can save it to an js array;
    then update the area with the first element.
    on next button click update the area with second element…
    hope it will help.

    in js you can do:

    index = 0;
    res_data = [];
    $.ajax({    
     type    : "POST",
     cache   : true,
     //dataType: "json",
     url     : "a.php",
     data    : {
                proid:id
              },                
      success: function(data) {
        $(data.html).each(function(k,v){
    
           res_data.push(v);
    
        });
        showNext();      
      }
    });
    
    
    function showNext(){
        $("#match_item_display").html(res_data[index]);
        index++;
    }
    
    function showPrev(){
        if(res_data[index-1] !== 'undefined'){
            $("#match_item_display").html(res_data[index-1]);
            index--;
        }
    }
    

    you can make the ajax call on load of the page.
    and assign the showNext() and showPrev to onclick events of next and prev button respectfully.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not very used to php, but I have made an index.php page
I have an index.php-file, which will echo the string with the returned .html-file prepared
I have an index.php file which has to process many different file types. How
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
Absolute beginner question: I have a template file index.html that looks like this: ...
I have an upload script that write a index.html file, I modified it to
I have a simple file called index.php. I need to pass it a querystring
I have included a file named test.php in the file index.php lets assume index.php
I have a bootstrap file which is index.php and I only allow this page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.