CodeIgniter Ajax $ _Post为空

时间:2011-08-02 23:55:18

标签: ajax codeigniter

相关的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);
});

相关控制器功能:

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

从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

当前回复:

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

Post In Firebug的Net Tab显示为Empty,服务器端的post变量为Empty。 JS调用有什么问题?

思考?

提前致谢!

编辑我也试过通过这个看看它是否在CodeIgniter的输入类中:

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

To No Success,它是布尔值False,因为Post Data为Empty。

2 个答案:

答案 0 :(得分:1)

您可能希望验证发送的对象,以确保它实际上将值发布到请求页面;)

答案 1 :(得分:0)

在codeignter上你不能在控制器上使用gzip压缩和“echo”,你必须使用视图输出

  

非常重要:如果在启用压缩时获得空白页,则意味着您过早地向浏览器输出内容。它甚至可以是你的一个脚本末尾的一行空格。要使压缩起作用,在输出类调用输出缓冲区之前不能发送任何内容。不要在启用压缩的情况下“回显”任何值。