如何重定向页面,然后使用ajax数据预先填充选项?

The situation is like this:

On page1.php, there's a grid of data, each row has a view link. Now, when I click a view link, it should redirect to another page, that would be page2.php. On page2.php, there are 5 checkboxes and an input form (it's actually a search option/feature with a submit button). I want to prefill those options from a data that was pulled from the db, which was based from the "ID" of the "view" link from page1.php and then show the results of the search thing based from the prefilled options. How should I pproach this?

Here's my current code

   $('.view').click(function(){
      var id = $(this).attr('id');
      var userid = $('#userid').val();
       window.location = './page2.php';
       //I don't really know what to do here.
       //assuming the db table is named testtable?
       //am i just gonna use $.ajax() ?, if so,how will i extract the returned data
       // in order to prefill the options on page2.php and at the same time
       // show the result of the search based from the prefilled options?

   });

Why do you need AJAX for this?

You can just set the HREF of your link to redirect to page2.php?var=smth and then use that value to extract info with php from the database, and populate the HTML form according to it.