Welcome Guest, Not a member yet? Register   Sign In
How to keep my ajax results and details in the same div so i can use the back button??
#1

[eluser]123wesweat[/eluser]
Hi,

I am stuck with the following, clicking the back button will not show the search results again but it shows just the regular overview.

Here's my controller setup:
controller jobs.php
function index() -> just an overview
function ajaxSearchJobs() ->returns a list of jobs base on searchFilters, will be loaded in a div

I am using jquery ajax call, which calls controller's method and outputs a list of jobs based on the different search filters.

This is the javascript i have in template.php view which holds the jquery and ajax function
Code:
function generate_query(){
    frm=document.forms["filterjobs"];
    qry="runquery=1";
    for(z=0;z<frm.elements.length;z++){
        if(frm.elements[z].type=="select-one" && frm.elements[z].options.selectedIndex>0){
            qry += "&" + frm.elements[z].name + "=" + frm.elements[z].options[frm.elements[z].options.selectedIndex].value;
        }
    }
//ajax querystring
    alert(qry);
    
    $.ajax({
       type: "POST",
       url: "jobs/ajaxSearchJobs",
       data: qry,
       beforeSend: function() { $('#wait').show(); },
           complete: function() { $('#wait').hide(); },
       success: function(msg){
           //check what is returned
         //alert( "Data Saved: " + msg );
         $('#searchResult').html(msg); // Fill the search results box
       }
     });
    //end search result
}

Explanation: Each dropdown menu triggers the javascript function generate_query() and shows a list of found jobs. But when you click on the details link of a particular job it calls
Code:
jobs/details/2134
and it shows the details.

But when you click the back button it doesn't show the previous result but the default overview.
How can i fix this??

Second question would be how i can get the pagination to work?


My ajaxSearchJobs method/function looks like this
Code:
function ajaxSearchJobs() {
        $runquery = isset($_POST['runquery']) ? $_POST['runquery'] :'';
        $searchItemA= isset($_POST['searchItemA']) ? $_POST['searchItemA'] :'';
$searchItemB= isset($_POST['searchItemB']) ? $_POST['searchItemB'] :'';
$searchItemC= isset($_POST['searchItemC']) ? $_POST['searchItemC'] :'';
$searchItemD= isset($_POST['searchItemD']) ? $_POST['searchItemD'] :'';
        if($runquery==1) {
            //search the DB
            $data['jobsfound'] = $this->jobs_model->filter_jobs($runquery, $searchItemA,$searchItemB,$searchItemC,$searchItemD);
            $data['tableResult'] = $this->load->view('vacatures/view_filter_results', $data, TRUE);
            //for ajax we just need to echo which is our msg var???
            echo $data['tableResult'];
            //$this->load->view('jobs/template', $data);//<-we don't need this????
        } else {
            //not direct access
            echo "No direct search";
        }
    }

regards
#2

[eluser]123wesweat[/eluser]
still need the help but i have come up with this detail page in the Ajax div

i added this javascript
Code:
function showJobDetails(jobid) {
    $.ajax({
       type: "POST",
       url: "jobs/details",
       //
       data: "jobid="+jobid,
       beforeSend: function() { $('#wait').show(); },
       complete: function() { $('#wait').hide(); },
       success: function(msg){
               //check what is returned
         alert( "Data Saved: " + msg );
         $('#searchResult').html(msg); // Fill the search results box
       }
     });
}

which calls the method details and in method details i do a boolean is_ajax() and echo the resulting jobdetails.

But still i can't get the back button behave like i want it to Sad




Theme © iAndrew 2016 - Forum software by © MyBB