EDITS: I have eliminated the variable var path that I had to indicated the URL to the controller and used the url itself, now the path error is gone but I get no data. Something in the communication of the files is not being passed on.
What I am trying to do is upon scrolling, have the page load data from the server. For that purpose I am using a separate jquery file, a view, the controller and the model.
JQUERY FILE. You will see it is pretty straightforward:
$(document).ready(function() {
var pageLoaded = 1; //this basically says that we are on page 1 of the results
$(window).scroll(function()
{
if($(window).scrollTop() == $(document).height() - $(window).height())
{
pageLoaded = pageLoaded+1; //when this condition has met, increase the pageLoaded so that I can tell php to load in data for page 2/3/4/5, etc, etc
/*// below I send the data to the controller named Home its function loadData gets a variable named id_load with value = to pageLoaded*/
$.get('home/loadData', {'id_load':pageLoaded},
function(data)
{
if (data != "")
{
$('#submissions').append(data);
}
}
);
//alert(pageLoaded);
}
}
);
});
CONTROLLER:
<?php if (! defined('BASEPATH')) exit ('No direct script access allowed');
class Home extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('load_model');
$this->output->enable_profiler(TRUE);
}
public function loadData ()
{
$pageNumber = $this->input->get('id_load');
$this->load_model->loadPage($pageNumber);
}
public function index()
{
$data = array('title' =>'homepage', 'main_content' =>'home_v');
$this->load->view('template', $data);
}
}
and the MODEL should display the content as it gets new values while u scroll:
<?php
class Load_model extends CI_Model {
public function loadPage ($pagenumber )
{
$sql = $this->db->where('id_load', $pagenumber)->get('data');
$cadena = "";
foreach($sql->result_array() as $reg)
{
$cadena = $reg['content'];
}
echo $cadena;
}
}