[英]CodeIgniter + AJAX Internal Error 500
I'm trying to make a ajax call to one method in my Notification controller. 我正在尝试对我的Notification控制器中的一个方法进行ajax调用。
My method is: 我的方法是:
public function testeAjax()
{
if($this->chamadaAjax())
echo 'Ajax';
else
echo 'Form';
}
The $this->chamadaAjax()
simply perform and $this->input->is_ajax_request()
$this->chamadaAjax()
简单执行, $this->input->is_ajax_request()
And this is my Ajax call: 这是我的Ajax电话:
$.ajax({
type: "POST",
url: '<?php echo base_url(); ?>/office/notificacao/testeAjax',
success: function(html) {
alert(html);
}
});
I have a form with two buttons, one for form submit and another for ajax request. 我有一个带有两个按钮的表单,一个用于表单提交,另一个用于ajax请求。
The thing is that when I add some data to the ajax like: data: "nome=Gerep", and call it, I receive a Internal Erro 500
事实是,当我向ajax中添加一些数据,例如:data:“ nome = Gerep”并调用它时,我收到一个
Internal Erro 500
When I don't send any data, it works, it returns me form when submitted and ajax when I call ajax request. 当我不发送任何数据,它的工作原理,它返回提交和Ajax当我打电话Ajax请求时,我的形成 。
Any ideas? 有任何想法吗?
EDIT Using FireBug here is what I get: 编辑使用FireBug,这是我得到的:
f.support.ajax.f.ajaxTransport.sendjquery-1.7.1.min.js:4
f.extend.ajaxjquery-1.7.1.min.js:4
testenotificacao:140
(anonymous function)notificacao:113
onclick
Are you passing the data in the URL or defining an object? 您是在URL中传递数据还是在定义对象? Ie: Data being passed (especially POST) should look something like this:
即:正在传递的数据(尤其是POST)应如下所示:
$.ajax({
type: "POST",
url: '<?php echo base_url(); ?>/office/notificacao/testeAjax',
data: { nome: "Gerep" },
success: function(html) {
alert(html);
}
});
and NOT like this: 而不是这样的:
$.ajax({
type: "POST",
url: '<?php echo base_url(); ?>/office/notificacao/testeAjax?nome=Gerep',
success: function(html) {
alert(html);
}
});
问题出在跨站点请求伪造 ,禁用它可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.