开发者

Mysterious jQuery AJAX bug wants more arguments

I user jQuery's ajax to sign up users. I use almost the exact code below to do similar stuff all over my site and yet for some reason the code be开发者_如何学Clow is throwing this error in Firebug.

Error:

uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js :: add :: line 5437" data: no]

Call:

lzaUserAPI.doAUserSignup(signupUsername, signupPassword, signupEmail, signupFullname, signupCompanyName, signupWebsite, signupPhone, lzaSigninup.onAUserSignedUp);

Ajax Function:

doAUserSignup : function(username, password, email, fullname, companyname, website, phone, callback){

    // Add to server
    var paras = {cmd : 'doAUserSignup', us: username, ps: password, em: email, flnm: fullname, cpnm: companyname, wbst: website, phne: phone};

    $.ajax({
        url: lzaUserAPI.m_url,
        dataType: "json",
        data: paras,
        success: function(ret){callback(ret)}
    });
},

Callback:

onAUserSignedUp : function (ret) {

    alert ('yea!!!');
    //Todo: log them in
}

Any ideas? Thanks in advance!


The problem is somewhere in the code that converts the data object. Since we can't see all the code where exactly is not clear. Here is what you do, change the code like this:

// var paras = {cmd : 'doAUserSignup', us: username, ps: password, em: email, flnm: fullname, cpnm: companyname, wbst: website, phne: phone};
var paras = {cmd : 'doAUserSignup'};

See if that works, if it does start adding elements in till you find the problem.


I don't think this would fix anything but you should change:

success: function(ret){callback(ret)}

to

success: callback

Because you already have the callback as a pointer. No reason to make it wrapped with another.


Just a heads up to anyone who encounters this... i looked for the reason that this happened for 2 hours before realizing i forgot to add the

.attr('value')

At the and of each value :(

Meaning i did this:

user_name: $('div#registrationForm').find('input#user_name'),
first_name: $('div#registrationForm').find('input#first_name'),

Instead of this:

user_name: $('div#registrationForm').find('input#user_name').attr('value'),
first_name: $('div#registrationForm').find('input#first_name').attr('value'),

Hope this helps to save someone the time!
Best Regards, Sagive

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜