52,797
社区成员
发帖
与我相关
我的任务
分享
...
//1.最里层执行Ajax.Request的函数
load : function(tag, callback){
//alert(this.path);
new Ajax.Request(this.path, {
encoding : 'GB2312',
method : 'post',
parameters : 'action=load&tag=' + tag,
asynchronous : true,
onSuccess : callback,
onFailure : function(){
$('status').innerHTML = 'Load failed.';
}
});
},
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
//2.外一层封装
loadJSON : function(tag, object, callback) {
if (object) {
this.json.load(tag, function(response){
//!IE内核在这里就不能获得response.responseText,但是firefox却没有问题
if(response && response.responseText) {
var jsonstr = response.responseText;
Object.extend(object, jsonstr.evalJSON());
} else {
object = null;
}
callback(object);
});
} else {
alert("need arg : object (Storage.loadJSON(tag, object))");
}
},
...