1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-direct.JsonProvider'>/**
2 </span> * @class Ext.direct.JsonProvider
3 * @extends Ext.direct.Provider
5 A base provider for communicating using JSON. This is an abstract class
6 and should not be instanced directly.
12 Ext.define('Ext.direct.JsonProvider', {
14 /* Begin Definitions */
16 extend: 'Ext.direct.Provider',
18 alias: 'direct.jsonprovider',
20 uses: ['Ext.direct.ExceptionEvent'],
24 <span id='Ext-direct.JsonProvider-method-parseResponse'> /**
25 </span> * Parse the JSON response
27 * @param {Object} response The XHR response object
28 * @return {Object} The data in the response.
30 parseResponse: function(response){
31 if (!Ext.isEmpty(response.responseText)) {
32 if (Ext.isObject(response.responseText)) {
33 return response.responseText;
35 return Ext.decode(response.responseText);
40 <span id='Ext-direct.JsonProvider-method-createEvents'> /**
41 </span> * Creates a set of events based on the XHR response
43 * @param {Object} response The XHR response
44 * @return {Array} An array of Ext.direct.Event
46 createEvents: function(response){
54 data = this.parseResponse(response);
56 event = Ext.create('Ext.direct.ExceptionEvent', {
59 code: Ext.direct.Manager.self.exceptions.PARSE,
60 message: 'Error parsing json response: \n\n ' + data
65 if (Ext.isArray(data)) {
66 for (len = data.length; i < len; ++i) {
67 events.push(this.createEvent(data[i]));
70 events.push(this.createEvent(data));
75 <span id='Ext-direct.JsonProvider-method-createEvent'> /**
76 </span> * Create an event from a response object
77 * @param {Object} response The XHR response object
78 * @return {Ext.direct.Event} The event
80 createEvent: function(response){
81 return Ext.create('direct.' + response.type, response);
83 });</pre></pre></body></html>