1 /**2 * Description: Manage ajax connections with a queue model.3 * Author: gerardooscarjt@gmail.com4 * Date: 2013/31/015 * Typical use:6 7 var ajax = new Ajax();8 ajax.setUrl('http://example.com/path');9 ajax.setMethod('post');10 ajax.setData({'name':'a','age':'22'};11 ajax.callback.done = function(xhr) {12 // ...13 };14 ajax.callback.error = function(xhr) {15 // ...16 };17 ajax.send();18 19 */20 var Ajax = function() {21 22 Ajax.prototype.requests.push(this);23 24 this._id = Ajax.prototype.id_generator;25 Ajax.prototype.id_generator++;26 27 28 }29 30 Ajax.prototype.requests = [];31 Ajax.prototype.queue = [];32 Ajax.prototype.id_generator = 0;33 34 window.addEventListener('load', function(){35 test1(); 36 }, true);37 38 39 /**40 * Launch 10 ajax calls41 */42 function test1() {43 var ajax = new Ajax();44 ajax.url = 'http://www.treeweb.es/request';45 ajax.callback.done = function(xhr){46 logger.log('');47 };48 ajax.send();49 50 }51 52 53 54 55 56
Este ShareCode tiene versiones:
- God Ajax ... (31/01/2013)
- God Ajax ... (24/04/2013)
- God Ajax ... (24/04/2013)
- God Ajax ... (24/04/2013)
- God Ajax ... (24/04/2013)
- God Ajax ... (24/04/2013)
Enlace
El enlace para compartir es: