DiscontentDisciple
DiscontentDisciple

Reputation: 466

CodeIgniter Ajax $_Post Is Empty

Relevant Javascript:

var tx = $("tx"+working_row).val();
var mods = $("mods"+working_row).val();
var pos = $("pos"+working_row).val();
var startdate = $("startdate"+working_row).val();
var enddate = $("enddate"+working_row).val();
var fordx = $("4dx"+working_row).val();
var qty = $("qty"+working_row).val();
var price = $("price"+working_row).val();
var token = $.cookie("csrf_cookie_name")
var obj = {"csrf_token_name": token, "tx" : tx, "mods":mods,"pos":pos,"startdate":startdate,"enddate":enddate,"fordx":fordx,"qty":qty,"price":price };
$.post("index.php/auth/fee_schedule",obj, function(data){
    alert(data);
});

Relevant Controller Function:

function fee_schedule(){
    echo var_dump($_POST);
}

Request Headers from Firebug:

Host    localhost
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1
Accept  */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection  keep-alive
X-Requested-With    XMLHttpRequest
Referer http://localhost/medata/
Cookie  ci_csrf_token=4330bb2c724341c409a53acabe14e04d; ci_session=AzcHaQViV2wGLgcmB2kBNQA%2FAToHIF1%2FCj4GIwNwBToCOlNuBwxeOgEwVyENZQJwDWRTMlA2UW5ec1Y2VzRUZwQxBmZXNQFvBDJUPlI1DmYDMwcwBTNXZwZiB2AHMgFmADcBOQc7XTgKPwZiA2cFYgJgU2UHNV5lATBXIQ1lAnANZFMwUDRRbl5zVj5XIlRaBDQGNFczASUENlR0UnUOIQNtByAFbFdvBm8HdwdiATYAOAEuBzJdIgprBn4DMgVxAm5TcwdpXmIBZFc5DXwCdg0tU2RQdlELXjBWMFc3VGsEIQZyV2wBJARpVDJSNg45A3QHHgU5VywGPAc5Bz8BZQAgATUHLF08CnsGeANUBToCO1NkBzxeJAEnVyMNEAJXDX5TN1AqUWVealZ3VwVUSgQCBmZXYwFsBHNUdVJwDjkDYwd9BWZXeAZkB3wHcwFDAGoBYwdpXS4KYAYjAzkFYgJmUzoHcV4%2FATVXcA0qAlwNP1NiUHBRPV4nVj5XJlR8BHcGa1c%2BAW0EYlQ0UjcOMQNlB2EFblduBmAHbAdoAXk%3D
Pragma  no-cache
Cache-Control   no-cache
Content-Length  0

Current Response:

<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b>
  <i><font color='#888a85'>empty</font></i>
</pre>

The Post In Firebug's Net Tab is showing as Empty, and the post Variable on the server side is Empty. What's wrong with the JS call?

Thoughts?

Thanks in Advance!

Edit I've also tried seeing if it's in CodeIgniter's Input Class via this:

$data = $this->input->post();
echo var_dump(data);

To No Success, it's a Boolean False because the Post Data is Empty.

Upvotes: 0

Views: 1121

Answers (2)

Cystack
Cystack

Reputation: 3561

You might want to validate your sent object to be sure that it is actually POSTing values to the request page ;)

Upvotes: 1

nirvanist
nirvanist

Reputation: 301

on codeignter you can't use gzip compression and "echo" on controller , you must use view for output

VERY IMPORTANT: If you are getting a blank page when compression is enabled it means you are prematurely outputting something to your browser. It could even be a line of whitespace at the end of one of your scripts. For compression to work, nothing can be sent before the output buffer is called by the output class. Do not "echo" any values with compression enabled.

Upvotes: 0

Related Questions