Ajax和jQuery一起工作

时间:2014-12-21 03:00:00

标签: jquery ajax

我正在使用Ajax和jQuery。我有这段代码:

      <fieldset id="question-1">
    <p>
      <label>Question 1</label>
    </p>
    <p>Login to the server via POST /users/sign_in.</p>
    <p>Print out your user info</p>
    <p>Hint: (Data: {user: {email: "your_franklin_email", password: "franklin!"}})</p>
    <p>(Keep a reference to the token as you'll need it in the next steps.)</p>
    <p class="output"></p>
  </fieldset>

和我的代码是:

var login = function(callback){
    $.ajax({
        url:baseURL + "/users/sign_in",
        type:"POST",
        data: "user[email]=nelson24%40email.franklin.edu&user[password]=franklin!",
        datatype:"json",
    }).success(function(arg1, arg2, jqXHR)){
        var result = "";
        $each(arg1, (function(key, value){
            if ("token" == key){
                token == value;
            } 
            result += key + ' ' + value;
        });
        $('#question-1 .output').html(result);
        callback (three);
    }

};

我做错了什么?

0 个答案:

没有答案