Sidetik
Sidetik

Reputation: 620

Can't send ajax request

I've got this code:

$('#clicker_continue').click(function(){
    $.ajax({
        type:'POST',
        url: 'includes/functions/register_user.php',
        data: {
            'username':dat_usr,
            'email':dat_email,
            'password':dat_pas,
            'question':dat_que,
            'answer':dat_ans,
            'ip':data.ip
        },  
        dataType:'html',
        succes:function(response){
            $('#main_wrapper').append(response);
        }
    }); 

When watching the Network Monitor and clicking on #clicker_continue, I don't see ajax requesting register_user.php. What is wrong here?

Upvotes: 0

Views: 74

Answers (2)

Ionică Bizău
Ionică Bizău

Reputation: 113485

First mistake is that you have a syntax error: SyntaxError: Unexpected end of input. }) is missing. This is probably your mistake that stops the request from being made.

Second one is that you have a typo: succes instead of success - this would not stop the request from being made but will not detect the response.

$('#clicker_continue').click(function(){
    $.ajax({
        type:'POST',
        url: 'includes/functions/register_user.php',
        data: {
            'username':dat_usr,
            'email':dat_email,
            'password':dat_pas,
            'question':dat_que,
            'answer':dat_ans,
            'ip':data.ip
        },  
        dataType:'html',
        success:function(response){
            $('#main_wrapper').append(response);
        }
    });
}); // <<< You missed this

Upvotes: 0

ajtrichards
ajtrichards

Reputation: 30565

Spelling mistake in your $.ajax call. You forget the extra s on the end of success:

$.ajax({
    type:'POST',
     url: 'includes/functions/register_user.php',
     data: {'username':dat_usr, 'email':dat_email, 'password':dat_pas, 'question':dat_que, 'answer':dat_ans  ,'ip':data.ip},
     dataType:'html',
     success:function(response){
         $('#main_wrapper').append(response);
    }
});

Upvotes: 1

Related Questions