2008-02-03
[prototype]向回调函数追加参数怎么不对?
function a(ID){
new Ajax.Request("xx.xx", {onComplete:getFunc(ID)});
function getFunc(ID){
return function(){
b.curry(ID);
}
}
}
function b(Data_ID, response){
new Insertion.After(Data_ID, response.responseText)
}
我向回调函数追加参数怎么不对?
我不知道我对curry的理解是否正确。。。
new Ajax.Request("xx.xx", {onComplete:getFunc(ID)});
function getFunc(ID){
return function(){
b.curry(ID);
}
}
}
function b(Data_ID, response){
new Insertion.After(Data_ID, response.responseText)
}
我向回调函数追加参数怎么不对?
我不知道我对curry的理解是否正确。。。
评论
hax
2008-04-14
curry的意思是逐个填充参数。
比如你有一个函数f(a,b,c),
f 如果被curry了之后,就允许
f1 = f(a) 然后 f1(b, c)
也可以 f2 = f1(b) 然后 f2(c)
比如你有一个函数f(a,b,c),
f 如果被curry了之后,就允许
f1 = f(a) 然后 f1(b, c)
也可以 f2 = f1(b) 然后 f2(c)
冯冀川
2008-04-13
我感觉最简单的追加方式:
var testAjax = Class.create({
initialize: function() {
},
ajax: function(pars) {
var GData_ID = pars;
var that = this;
new Ajax.Request("../AjaxMethod.aspx", {
method: "get",
onComplete: that.getFunc.bind(that, GData_ID),
parameters: "MethodName=Show_maga_BundelDetail_Tr&PKID=" + GData_ID
});
},
getFunc: function(GData_ID, response) {
alert(GData_ID);
}
});
var test = new testAjax();
在prototype.js-1.6里面curry的实现和bind基本类似
var testAjax = Class.create({
initialize: function() {
},
ajax: function(pars) {
var GData_ID = pars;
var that = this;
new Ajax.Request("../AjaxMethod.aspx", {
method: "get",
onComplete: that.getFunc.bind(that, GData_ID),
parameters: "MethodName=Show_maga_BundelDetail_Tr&PKID=" + GData_ID
});
},
getFunc: function(GData_ID, response) {
alert(GData_ID);
}
});
var test = new testAjax();
在prototype.js-1.6里面curry的实现和bind基本类似
faichan
2008-03-04
zhangliang25m 写道
我忘记了Ajax还有缓存一说,所以每次都不刷新,这个问题浪费了我半天。。。,我一直以为是我的curry理解有错误,所以看问题要多方面考虑。。
curry是什么函数?
可以给它的语法我吗
zhangliang25m
2008-02-03
我忘记了Ajax还有缓存一说,所以每次都不刷新,这个问题浪费了我半天。。。,我一直以为是我的curry理解有错误,所以看问题要多方面考虑。。
zhangliang25m
2008-02-03
这个问题我解决了
在1.6版本:
function Lookmaga_BundelDetail(ID){
DeleteTr();
GData_ID = String.interpret(ID);
new Ajax.Request("../AjaxMethod.aspx", {
method: "get",
onComplete: Show_maga_BundelDetail_Tr.curry(GData_ID),
parameters: "MethodName=Show_maga_BundelDetail_Tr&PKID=" + GData_ID+ "&t="+new Date().getTime()
});
}
在1.6以前:
function Lookmaga_BundelDetail(ID){
GData_ID = String.interpret(ID);
new Ajax.Request("../AjaxMethod.aspx", {
method: "get",
onComplete: getFunc(GData_ID),
parameters: "MethodName=Show_maga_BundelDetail_Tr&PKID=" + GData_ID
});
function getFunc(id){
return function(req){
new Insertion.After(id,req.responseText);
}
}
}
在1.6版本:
function Lookmaga_BundelDetail(ID){
DeleteTr();
GData_ID = String.interpret(ID);
new Ajax.Request("../AjaxMethod.aspx", {
method: "get",
onComplete: Show_maga_BundelDetail_Tr.curry(GData_ID),
parameters: "MethodName=Show_maga_BundelDetail_Tr&PKID=" + GData_ID+ "&t="+new Date().getTime()
});
}
在1.6以前:
function Lookmaga_BundelDetail(ID){
GData_ID = String.interpret(ID);
new Ajax.Request("../AjaxMethod.aspx", {
method: "get",
onComplete: getFunc(GData_ID),
parameters: "MethodName=Show_maga_BundelDetail_Tr&PKID=" + GData_ID
});
function getFunc(id){
return function(req){
new Insertion.After(id,req.responseText);
}
}
}
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 143 次
- 性别:

- 来自: 上海

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
[prototype]向回调函数追 ...
curry的意思是逐个填充参数。比如你有一个函数f(a,b,c),f 如果被cu ...
-- by hax -
[prototype]向回调函数追 ...
我感觉最简单的追加方式: var testAjax = Class.creat ...
-- by 冯冀川 -
[prototype]向回调函数追 ...
zhangliang25m 写道我忘记了Ajax还有缓存一说,所以每次都不刷新, ...
-- by faichan -
[prototype]向回调函数追 ...
我忘记了Ajax还有缓存一说,所以每次都不刷新,这个问题浪费了我半天。。。,我一 ...
-- by zhangliang25m -
[prototype]向回调函数追 ...
这个问题我解决了 在1.6版本: function Lookmaga_Bunde ...
-- by zhangliang25m






评论排行榜