代码之家  ›  专栏  ›  技术社区  ›  Kyle Cureau

神秘的jQuery AJAX错误需要更多的参数

  •  4
  • Kyle Cureau  · 技术社区  · 14 年前

    错误:

    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]

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

    Ajax函数:

    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)}
        });
    },
    

    onAUserSignedUp : function (ret) {
    
        alert ('yea!!!');
        //Todo: log them in
    }
    

    有什么想法吗?提前谢谢!

    3 回复  |  直到 14 年前
        1
  •  9
  •   Hogan    14 年前

    问题出在转换数据对象的代码中。因为我们看不到所有的代码,哪里不清楚。下面是您所做的,更改代码如下:

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

        2
  •  3
  •   Amir Raminfar Hadi Rasouli    14 年前

    我认为这不会解决任何问题,但你应该改变:

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

    success: callback
    

    因为您已经将回调作为指针。没有理由用另一个包起来。

        3
  •  0
  •   Sagive    12 年前

    对任何遇到这种情况的人都是一种提醒。。。我找了两个小时才发现我忘了加上

    .attr('value')
    

    意思是我这么做了:

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

    而不是这个:

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


    祝你好运,萨吉夫