Javascript 邮递http://localhost/myapp/index.php/myCon/verification 500(内部服务器错误)
这里我检查用户输入的代码是否与我在视图中提出AJAX请求的数据库中的代码相同。在另一个函数中,我使用了相同的代码,在那里发送了请求,我收到了响应,但这里得到了错误“POST 500(内部服务器错误)”。我找不到导致那个错误的原因 基本URL:Javascript 邮递http://localhost/myapp/index.php/myCon/verification 500(内部服务器错误),javascript,php,mysql,ajax,codeigniter,Javascript,Php,Mysql,Ajax,Codeigniter,这里我检查用户输入的代码是否与我在视图中提出AJAX请求的数据库中的代码相同。在另一个函数中,我使用了相同的代码,在那里发送了请求,我收到了响应,但这里得到了错误“POST 500(内部服务器错误)”。我找不到导致那个错误的原因 基本URL: $config['base_url'] = 'http://localhost/myapp/'; 视图: 函数newPass(){ var temp=jQuery(“#代码”).val(); console.log('代码:'+temp); jQuer
$config['base_url'] = 'http://localhost/myapp/';
视图:
函数newPass(){
var temp=jQuery(“#代码”).val();
console.log('代码:'+temp);
jQuery.ajax({
键入:“POST”,
数据类型:“json”,
url:“index.php/myCon/verification”,//**此处出现错误**
数据:{“temp”:temp},
成功:功能(响应){
控制台日志(“响应”+响应);
var msg=response.message;
var stat=响应状态;
如果(stat=='success'){
//一些声明
}
否则{
document.getElementById('msg')。innerHTML='error code';
}
},
错误:函数(XMLHttpRequest、textStatus、ErrorSprown){
console.log(“状态:+textStatus”);console.log(“错误:+errorshown”);
}
});
}
控制器:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
*
*/
class MyCon extends CI_Controller
{
function __construct() {
parent::__construct();
}
//there is another function in which am calling AJAX request too it is working but am getting error while calling this verification.
public function verification(){
if ($this->input->is_ajax_request()) {
$this->load->model('CustomerModel');
$res = $this->CustomerModel->checkCode();
echo "count:".$res->num_rows(); // this caused the problem
if(!empty($res)) {
$data['status'] = 'success';
$data['message'] = 'code found';
} else {
$data['status'] = 'error';
$data['message'] = 'Data not found';
}
echo json_encode($data);
exit;
}
else{
redirect('index.php/myCon/fp_confirm');
}
}
}
?>
型号:
<?php
class CustomerModel extends CI_Model{
function __construct()
{
parent:: __construct();
}
function checkCode(){
$code = $this->input->post('temp');
$result = $this->db->get_where('privilege_customer', array('code_password' => $code));
return $result->result();
}
}
?>
echo“count:”.$res->num_rows();//这就造成了问题
我在控制器中调用了num_rows()函数。日志文件中出现以下错误:“严重性:错误-->调用数组上的成员函数num_rows()”
我已经删除了echo语句,它成功了。您应该启用错误显示和/或检查服务器的错误日志,以查看错误的具体内容。
myCon
controller在这段代码中的位置?@PankajMakwana hahah fogot更改它。现在检查我编辑的代码。尝试使用base_url而不是site_url…@Mahesh无更改仍然会收到相同的错误。
<?php
class CustomerModel extends CI_Model{
function __construct()
{
parent:: __construct();
}
function checkCode(){
$code = $this->input->post('temp');
$result = $this->db->get_where('privilege_customer', array('code_password' => $code));
return $result->result();
}
}
?>