Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        11年前关闭。
                                                                                            
                
        
您如何从请求中访问响应
对象在MooTools中?我一直在看文档和MooTorial,但是
我似乎没有任何进展。我做过的其他Ajax东西
MooTools我根本不需要操纵响应,所以我只是
能够将其直接注入文档中,但是现在我需要
首先对其进行一些更改。我不想提醒响应,我想访问它,以便可以对其进行进一步的更改。任何帮助将不胜感激。
谢谢。

编辑:

我希望能够访问
请求发出后的响应,最好是
在Request对象之外。用于RSS阅读器,所以我需要做
一些解析和请求仅用于从
服务器文件。此函数是类中的方法,应返回
响应以字符串形式显示,但除了返回什么都没有
未定义:

        fetch: function(site){
                var feed;
                var req = new Request({
                        method: this.options.method,
                        url: this.options.rssFetchPath,
                        data: { 'url' : site },
            onRequest: function() {
                                if (this.options.targetId) { $
(this.options.targetId).setProperty('html',
this.options.onRequestMessage); }
                        }.bind(this),
                        onSuccess: function(responseText) {
                                feed = responseText;
                        }
                });
                req.send();
                return feed;
        }

最佳答案

响应内容返回到onComplete中定义的匿名函数。

可以从那里访问它。

var req = new Request({
    method: 'get',
    url: ...,
    data: ...,
    onRequest: function() { alert('Request made. Please wait...'); },

    // the response is passed to the callback as the first parameter
    onComplete: function(response) { alert('Response: ' + response); }

}).send();

10-04 16:52
查看更多