admin管理员组

文章数量:1387324

I was looking at the following code at .js

specifically this section,

Chat.fetch = function(callback){
    $.ajax({
        url: "",
        success: function(responseData){
            var messageList = [];
            var responseMessages = responseData.results;
            for (var i = 0; i < 10; i++) {
                messageList.push(responseMessages[i].text);
            };
            //Newest message is at index 0.  Reverse message list to add newest     messages to the bottom.
            callback(messageList.reverse());
        }
    });
};

I was wondering if anyone could tell me what this .results function does? I have already tried googling and even looked at the jQuery api documentation and can only find a .result function.

"event.result" = The last value returned by an event handler that was triggered by this event, unless the value was undefined.

Is this .result the same as .results?

Thank you

I was looking at the following code at https://github./JosephRobertBrown/HackReactorApplication/blob/master/TakeHomeProject/s.js

specifically this section,

Chat.fetch = function(callback){
    $.ajax({
        url: "https://api.parse./1/classes/chats?order=-createdAt",
        success: function(responseData){
            var messageList = [];
            var responseMessages = responseData.results;
            for (var i = 0; i < 10; i++) {
                messageList.push(responseMessages[i].text);
            };
            //Newest message is at index 0.  Reverse message list to add newest     messages to the bottom.
            callback(messageList.reverse());
        }
    });
};

I was wondering if anyone could tell me what this .results function does? I have already tried googling and even looked at the jQuery api documentation and can only find a .result function.

"event.result" = The last value returned by an event handler that was triggered by this event, unless the value was undefined.

Is this .result the same as .results?

Thank you

Share Improve this question asked Jul 8, 2013 at 3:30 JaToJaTo 2,8324 gold badges30 silver badges39 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

responseData.results is not a function. responseData is an object that has a key results, which then also has a key text which is then being added to an array and sent to a callback function, in reverse.

本文标签: Difference between results function and result function in javascriptjqueryStack Overflow