[ Index ] |
|
Code source de Seagull 0.6.1 |
1 /** 2 * Class that is used by generated stubs to make actual AJAX calls 3 * 4 * @category HTML 5 * @package AJAX 6 * @author Joshua Eichorn <josh@bluga.net> 7 * @copyright 2005 Joshua Eichorn 8 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL 9 */ 10 function HTML_AJAX_Dispatcher(className,mode,callback,serverUrl,serializerType) 11 { 12 this.className = className; 13 this.mode = mode; 14 this.callback = callback; 15 this.serializerType = serializerType; 16 17 if (serverUrl) { 18 this.serverUrl = serverUrl 19 } 20 else { 21 this.serverUrl = window.location; 22 } 23 } 24 25 HTML_AJAX_Dispatcher.prototype = { 26 /** 27 * Queue to use when making a request 28 */ 29 queue: 'default', 30 31 /** 32 * Timeout for async calls 33 */ 34 timeout: 20000, 35 36 /** 37 * Default request priority 38 */ 39 priority: 0, 40 41 /** 42 * Request options 43 */ 44 options: {}, 45 46 /** 47 * Make an ajax call 48 * 49 * @param string callName 50 * @param Array args arguments to the report method 51 */ 52 doCall: function(callName,args) 53 { 54 var request = new HTML_AJAX_Request(); 55 request.requestUrl = this.serverUrl; 56 request.className = this.className; 57 request.methodName = callName; 58 request.timeout = this.timeout; 59 request.contentType = this.contentType; 60 request.serializer = eval('new HTML_AJAX_Serialize_'+this.serializerType); 61 request.queue = this.queue; 62 request.priority = this.priority; 63 64 for(var i in this.options) { 65 request[i] = this.options[i]; 66 } 67 68 for(var i=0; i < args.length; i++) { 69 request.addArg(i,args[i]); 70 }; 71 72 if ( this.mode == "async" ) { 73 request.isAsync = true; 74 if (this.callback[callName]) { 75 var self = this; 76 request.callback = function(result) { self.callback[callName](result); } 77 } 78 79 } else { 80 request.isAsync = false; 81 } 82 83 return HTML_AJAX.makeRequest(request); 84 }, 85 86 Sync: function() 87 { 88 this.mode = 'sync'; 89 }, 90 91 Async: function(callback) 92 { 93 this.mode = 'async'; 94 if (callback) { 95 this.callback = callback; 96 } 97 } 98 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 01:27:52 2007 | par Balluche grâce à PHPXref 0.7 |