论坛首页 AJAX版 prototype

[prototype]向回调函数追加参数怎么不对?

浏览 753 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
时间:2008-02-03
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的理解是否正确。。。
   
时间: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);
}
}
}
   
0 请登录后投票
时间:2008-02-03
我忘记了Ajax还有缓存一说,所以每次都不刷新,这个问题浪费了我半天。。。,我一直以为是我的curry理解有错误,所以看问题要多方面考虑。。
   
0 请登录后投票
时间:2008-03-04
zhangliang25m 写道
我忘记了Ajax还有缓存一说,所以每次都不刷新,这个问题浪费了我半天。。。,我一直以为是我的curry理解有错误,所以看问题要多方面考虑。。


curry是什么函数?
可以给它的语法我吗
   
0 请登录后投票
时间: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基本类似
   
0 请登录后投票
时间:2008-04-14
curry的意思是逐个填充参数。
比如你有一个函数f(a,b,c),
f 如果被curry了之后,就允许
f1 = f(a) 然后 f1(b, c)
也可以 f2 = f1(b) 然后 f2(c)
   
0 请登录后投票
论坛首页 AJAX版 prototype

跳转论坛:
JavaEye推荐
    快速回复 引用上一条消息 (Alt+S)