如何在codeigniter中将ajax值传递给控制器

时间:2015-05-10 07:08:32

标签: php ajax codeigniter

我正在尝试使用Ajax将值传递给控制器​​。但是我无法成功实现这一目标。然而,相同的方法在其他应用程序中运行良好,我没有使用Codeigniter。

fblogin.js

function getUserInfo() {
    FB.api('/me', function(response) {

  //removed to shorten the code

    $.ajax({
    type: "POST",
    url: "http://localhost:8080/auth/login",
    data: {fbname: name, 
           fbid: id, 
           fbemail: email, 
           fbgender: gender,               
           fbimageURL: imageURL},
    success: function(data){
    /*This will be changed using a Ajax function on a later date so that the data is updated without page refresh*/ 
    console.log("Data sent to server");
    confirm("You have successfully logged in with FB");
    window.location.reload();
    }
});

});
}

Controller(Auth.php)

class Auth extends CI_Controller {

public function __construct() {

    parent::__construct();       
    $this->load->model('user_model');
}

public function login() { 

    $this->load->view('templates/pop_up_header.php');
    $this->load->view('app/');
    $this->load->view('templates/footer');
}
}

我在这里遇到的错误是

POST http://localhost:8080/auth/login 500 (Internal Server Error) 

我该如何解决这个问题?我是Codeigniter的新手。

0 个答案:

没有答案