/*!
- * Ext JS Library 3.0.0
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.1.1
+ * Copyright(c) 2006-2010 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
if (scriptTag) {\r
out.write(");");\r
}\r
+</code></pre>\r
+ * <p>Below is a PHP example to do the same thing:</p><pre><code>\r
+$callback = $_REQUEST['callback'];\r
+\r
+// Create the output object.\r
+$output = array('a' => 'Apple', 'b' => 'Banana');\r
+\r
+//start output\r
+if ($callback) {\r
+ header('Content-Type: text/javascript');\r
+ echo $callback . '(' . json_encode($output) . ');';\r
+} else {\r
+ header('Content-Type: application/x-json');\r
+ echo json_encode($output);\r
+}\r
+</code></pre>\r
+ * <p>Below is the ASP.Net code to do the same thing:</p><pre><code>\r
+String jsonString = "{success: true}";\r
+String cb = Request.Params.Get("callback");\r
+String responseString = "";\r
+if (!String.IsNullOrEmpty(cb)) {\r
+ responseString = cb + "(" + jsonString + ")";\r
+} else {\r
+ responseString = jsonString;\r
+}\r
+Response.Write(responseString);\r
</code></pre>\r
*\r
* @constructor\r
* <li>The "arg" argument from the load function</li>\r
* <li>A boolean success indicator</li>\r
* </ul>\r
- * @param {Object} scope The scope in which to call the callback\r
+ * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the browser window.\r
* @param {Object} arg An optional argument which is passed to the callback as its second parameter.\r
*/\r
doRequest : function(action, rs, params, reader, callback, scope, arg) {\r
* @param {String} action [Ext.data.Api.actions.create|read|update|destroy]\r
* @param {Object} trans The request transaction object\r
* @param {Object} res The server response\r
- * @private\r
+ * @protected\r
*/\r
onRead : function(action, trans, res) {\r
var result;\r
* @param {String} action [Ext.data.Api.actions.create|read|update|destroy]\r
* @param {Object} trans The request transaction object\r
* @param {Object} res The server response\r
- * @private\r
+ * @protected\r
*/\r
- onWrite : function(action, trans, res, rs) {\r
+ onWrite : function(action, trans, response, rs) {\r
var reader = trans.reader;\r
try {\r
// though we already have a response object here in STP, run through readResponse to catch any meta-data exceptions.\r
- reader.readResponse(action, res);\r
+ var res = reader.readResponse(action, response);\r
} catch (e) {\r
this.fireEvent('exception', this, 'response', action, trans, res, e);\r
trans.callback.call(trans.scope||window, null, res, false);\r
return;\r
}\r
- if(!res[reader.meta.successProperty] === true){\r
+ if(!res.success === true){\r
this.fireEvent('exception', this, 'remote', action, trans, res, rs);\r
trans.callback.call(trans.scope||window, null, res, false);\r
return;\r
}\r
- this.fireEvent("write", this, action, res[reader.meta.root], res, rs, trans.arg );\r
- trans.callback.call(trans.scope||window, res[reader.meta.root], res, true);\r
+ this.fireEvent("write", this, action, res.data, res, rs, trans.arg );\r
+ trans.callback.call(trans.scope||window, res.data, res, true);\r
},\r
\r
// private\r