<html>\r
<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
<title>The source code</title>\r
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
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
*\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
}\r
};\r
},\r
- /**\r
+ <div id="method-Ext.data.ScriptTagProxy-onRead"></div>/**\r
* Callback for read actions\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
}\r
trans.callback.call(trans.scope||window, result, trans.arg, result.success);\r
},\r
- /**\r
+ <div id="method-Ext.data.ScriptTagProxy-onWrite"></div>/**\r
* Callback for write actions\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