Post values not send through with ajax and $this->input->post(); |
[eluser]karimmaassen[/eluser]
In my home view, I created this form: Code: <div id="login-signup-form"> With some basic javascript (thanks to Nettuts) I try to implement some ajax: Code: $('#login_submit').click(function() { As you can see, it sends the form values to the login controller. The Login controller: Code: class Login extends CI_Controller { The problem is, it doesn't work. The function `$this->input->is_ajax_request()` outputs FALSE. Ignoring that, `$this->input->post('username')` won't give me the username. It seems that post data isn't put through. Is this a bug or a known issue or am I just doing something wrong?
[eluser]karimmaassen[/eluser]
The problem is in the javascript. The url needs a trailing slash. So, Code: login/ Code: login Anyone who knows why this is essential?
[eluser]Ken Verhaegen[/eluser]
[quote author="Kriem" date="1304352975"]The problem is in the javascript. The url needs a trailing slash. So, Code: login/ Code: login Anyone who knows why this is essential?[/quote] The problem is that you have specified a relative path for your redirect url to the Ajax controller. You need to make them absolute, or at least relative to the current location. That is to say, for example, if you change your image path from: Code: <img src="images/logo.png"> Code: <img src="/images/logo.png"> Code: <img src="http://www.domain.com/images/logo.png"> More info about "why" can be found @ This eFreeDom Question
|
Welcome Guest, Not a member yet? Register Sign In |