Search code examples
ajaxjqueryjquery-post

jQuery Ajax not executing


Greeting.

I have made this jQuery Ajax call, which doesn't seems to be executing.

It does handle the .live() call, but not the .ajax() call.

Any ideas?

Source of ajax.js:

$("#action_login").live("click", function() {
    var username = $("#login_form input.username").val();
    var password = $("#login_form input.password").val();
    alert("Username: " + username + "/nPassword: " + password);
    $("#login_form .status").ajax({
        type: 'POST',
        url: 'ajax/login.php',
        data: {
            'username': username,
            'password': password
        },
        success: function(data) {
            alert(data);
        },
        error: function(data) {
            alert("error" + data);
        },
        dataType: dataType
    });
});

It does call the first alert(); command, with the right value from the inputs for username and password, but after that nothing happens.

Hope someone can help me out.


Solution

  • $("#login_form .status") is the call to the $ function with "#login_form .status" as parameter.

    It returns a very different object than $, and it doesn't have any ajax function.

    So, replace

    $("#login_form .status").ajax(
    

    with

    $.ajax(