1 //<script type="text/javascript">
4 * Handles generic requests - an extension of Roo.data.Connection that runs the request
5 * on construction. shows error messages, and parses results.
8 var t = new Pman.Request({
9 url: baseURL + '/Images/Download/0/myfile.jpg',
11 success : function(res) {
16 failure : function () {
24 * @param {Object} cfg Configuration object.
25 * @cfg {String} url Location to download from.
26 * @cfg {String} method GET or POST (default GET), POST will create a form, and post that into the hidden frame.
27 * @cfg {Object/String/Function} params (Optional) An object containing properties which are used as parameters to the
28 * request, a url encoded string or a function to call to get either.
29 * @cfg {Function} success called with ( JSON decoded data of the data.. )
32 Pman.Request = function(config){
34 Pman.Request.superclass.constructor.call(this, config);
38 Roo.extend(Pman.Request, Roo.data.Connection, {
40 processResponse : function(response) {
44 res = Roo.decode(response.responseText);
46 if (typeof(res) != 'object') {
47 res = { success : false, errorMsg : res, errors : true };
49 if (typeof(res.success) == 'undefined') {
54 res = { success : false, errorMsg : response.responseText, errors : true };
59 handleResponse : function(response){
61 var options = response.argument.options;
62 response.argument = options ? options.argument : null;
63 this.fireEvent("requestcomplete", this, response, options);
65 var res = this.processResponse(response);
67 if (!res.success) { // error!
68 if (options.failure) {
69 // failure is handled... - do not show error..
70 if (true === Roo.callback(options.failure, options.scope, [res, options])) {
74 Roo.MessageBox.hide(); // hide any existing messages..
75 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
78 Roo.callback(options.success, options.scope, [res, options]);
81 handleFailure : function(response, e){
83 var options = response.argument.options;
84 response.argument = options ? options.argument : null;
85 this.fireEvent("requestexception", this, response, options, e);
86 Roo.callback(options.failure, options.scope, [response, options]);
87 Roo.callback(options.callback, options.scope, [options, false, response]);
88 if (!options.failure) {
89 Roo.MessageBox.hide(); // hide any existing messages..
90 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");