最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Difference between .results function and .result function in javascriptjquery? - Stack Overflow

programmeradmin3浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论