Welcome Guest, Not a member yet? Register   Sign In
SOLVED: Missing POST data
#1

[eluser]hazy[/eluser]
I hope someone will be able to see the error I am making - but cant find!

My page POSTs back ajaxwise to my controller function, the controller responds as it should but doesnt take the $_POST array into account. Indeed the Profiler confirms that it doesnt even have any POST data to deal with. But the POST data is there to be seen in Firebug!

Code snippets follow:

JS post
Code:
...
  $.ajax({ url:       'index.php/manufacturer/listRows/',
           data:      '{start : 20}',
           type:      'POST',
           timeout:   1000,
           error:     function(){
                        alert('Error loading document');
                      },
           success:   function(html){              
                        $(html).appendTo($('#main_content').empty());
                      });
    ...

CI Controller
Code:
function listRows($rowCountLimit=20, $rowOffset=0, $includeAdmin=false)
    {
    
        $this->output->enable_profiler(TRUE);
    
      // These never get set
      $rowCountLimit = $this->input->post('limit');
      $rowOffset = $this->input->post('start');
          
        echo 'POST DATA';  
        foreach ($_POST as $postvar) {
           // Nothing shows here
           echo 'Post item: '.$postvar;
        }
        
      $sortCol = 'Id';
      $sortDir = 'ASC';
      if (array_key_exists('sort', $_POST)) {
        $sortCol = $_POST['sort'];
        if (array_key_exists('dir', $_POST)) {
          $sortDir = $_POST['dir'];
        }
      }
            
      $resultSet = $this->getSome($rowCountLimit, $rowOffset, $sortCol, $sortDir);

      ...

Firebug
Code:
{start : 20}

Thanks in advance for all and any thoughts or suggestions on how to debug this problem.

EDIT: SHould be sending name=value&name=value string not json object. DOH!




Theme © iAndrew 2016 - Forum software by © MyBB