CXPOwen 2009-08-03
代码如下:
var Ajax = {}; Ajax.get = function(url, data) { var operation = new Async.Operation(); $.get(url, data, function(result) { operation.yield(result); }, "json"); return operation; }; Ajax.post = function(url, data) { var operation = new Async.Operation(); $.post(url, data, function(result) { operation.yield(result); }, "json"); return operation; };
代码如下:
function get(name) { return Ajax.get("/friend", "name=" + encodeURIComponent(name)); }
代码如下:
function get(name) { var operation = new Async.Operation() Ajax.get("/friend", "name=" + encodeURIComponent(name)) .addCallback(function(json) { operation.yield(createFriendFromJson(json)); }); return operation; }
代码如下:
function getAll(){ var operation = new Async.Operation(); var friends = []; var chain = Async.chain(); Ajax.get("/friendlist", "") .addCallback(function(json) { for (var i = 0; i < json.length; i++) { chain.next(function() { return get(json.shift()) .addCallback(function(friend) { friends.push(friend); }); }); } chain .next(function() { operation.yield(friends); }) .go(); }) return operation; }
代码如下:
Async.wait = function(delay, context) { var operation = new Async.Operation(); setTimeout(function() { operation.yield(context); }, delay); return operation; }; Async.Operation.prototype.wait = function(delay, context) { this.next(function(context) { return Async.wait(delay, context); }); }
代码如下:
for (var i = 0; i < json.length; i++) { chain .wait(500) .next(function() { return get(json.shift()) .addCallback(function(friend) { friends.push(friend); }); }); }
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
本文实例讲述了php+ ajax 实现的写入数据库操作。分享给大家供大家参考,具体如下:。<input class="tel" type="text" placeholder="请输入您的手机号码&q