• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A problem with a simple code jquery/ajax.

Hello everyone and thanks for reading this message.

I have a problem that can not find reason to not work.

I am creating a validation for a user registration form with CodeIgniter, and I have a javascript file with this code:

    $('#username').bind('blur', function(){

        var username = $(this).val();
        var datos = {
                field_username: username
            url: "users/username_check_ajax",
            type: 'post',

            data: datos,
            success: function(msg){

The only thing that makes this code is showing a warning screen with a message, when the user completes the 'field_username' (username in DB), which of course is a field that I have defined.

The method code of username_check_ajax is as follows:

function username_check_ajax()
        echo $this->input->post('field_username');

As you can see nothing special, but the problem is that to check the result, the screen shows the alert, but does not appear the text of the function username_check_ajax.

I tried a thousand things, but can not get any satisfactory results.

Of course, other codes in the method username_check_ajax, such as the following, also shows me the text message alert:

function username_check_ajax()
        echo "Hello World";

Does anyone have any idea where is the bug in my code?. THANKS.

Don't use relative paths. If you looked with firebug, I bet you would see that the request isn't being sent properly.

CroNiX, thousands of thanks.

Missing a slash at the beginning of the route :down:
I've taken a whole day trying codes, and finally the problem was less thinking.

Thank you very much for your help, I owe you one ;-)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.