source: Dev/trunk/src/client/dojox/mobile/dh/UrlDataSource.js @ 483

Last change on this file since 483 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 903 bytes
Line 
1define([
2        "dojo/_base/declare",
3        "dojo/_base/lang",
4        "dojo/_base/xhr"
5], function(declare, lang, xhr){
6
7        // module:
8        //              dojox/mobile/dh/UrlDataSource
9
10        return declare("dojox.mobile.dh.UrlDataSource", null, {
11                // summary:
12                //              A component that accesses the given URL and fetches the data as text.
13
14                text: "",
15
16                _url: "",
17
18                constructor: function(/*String*/ url){
19                        // summary:
20                        //              Creates a new instance of the class.
21                        this._url = url;
22                },
23
24                getData: function(){
25                        // summary:
26                        //              Returns a Deferred that accesses the given URL and fetches the data as text.
27                        var obj = xhr.get({
28                                url: this._url,
29                                handleAs: "text"
30                        });
31                        obj.addCallback(lang.hitch(this, function(response, ioArgs){
32                                this.text = response;
33                        }));
34                        obj.addErrback(function(error){
35                                console.log("Failed to load "+this._url+"\n"+(error.description||error));
36                        });
37                        return obj; // Deferred
38                }
39        });
40});
Note: See TracBrowser for help on using the repository browser.