I want to add ajax call instead of redirecting to the same page but with a parameter in url.
The code from where I am generating the redirect call is following

Maps.min.js

var temp_ = t.getMarkers(), temp_pids = [];
                    for(var v=0;v<temp_.length;v++){
                                1==temp_[v].visible&&(asdf++,temp_pids.push(temp_[v].id));
                            }


                            relink = "http://localhost/wordpres/?pid=";
                            relink = relink + temp_pids; 
                            window.location.replace(relink);

The variable pid is populated with the post ids and sent to the same page through url.

the code where these pids are get is following

Front-page.php

<?php if( isset ( $_GET["pid"] )){
            $thePostIdArray = explode(',', $_GET['pid']);
             $args = array(
                   'post__in'      => $thePostIdArray
                );

                query_posts($args);?>
             <?php while (have_posts()) : the_post(); ?>
                <?php
                if ('posts' == get_option('show_on_front')) {
                    get_template_part('content', 'posts');
                } else {
                    get_template_part('content', 'page');
                }


                ?>
            <?php endwhile; // end of the loop.   
        }else{
        ?>
            <?php while (have_posts()) : the_post(); ?>
                <?php
                if ('posts' == get_option('show_on_front')) {
                    get_template_part('content', 'posts');
                } else {
                    get_template_part('content', 'page');
                }
                // If comments are open or we have at least one comment, load up the comment template
                if (comments_open() || '0' != get_comments_number()) :
                    comments_template();
                endif;
                ?>
            <?php endwhile;} // end of the loop.   ?>

To visualize whats happening you can visit http://boligbilder.no and click any cluster on the map.

Need help to convert this to ajax call

Read more here: Add ajax instead of redirecting to same page with parameter in url using get method


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: