标签:
Ecstore的JS框架使用了mootools,所以ajax调用也使用mootools中的Request组件。
var myRequest = new Request([options]);
看ecstore中的一个例子:
new Request({url:‘index.php?app=b2c&ctl=admin_specification&act=check_spec_value_id‘,
onSuccess:function(re){
if(re==‘can‘){
row.remove();
}else{
MessageBox.error(re);
}
}
}).post(‘spec_value_id=‘+encodeURIComponent(specvid));
onSuccess是在ajax调用成功后返回,参数是响应内容ResponseText
Request还有两个扩展类:
Request.HTML 专门用于响应内容为HTML的请求,重要的参数有:
update - (element: 默认为 null) 请求响应的responseText要插入的目标元素
evalScripts - (boolean: 默认为 true) 如果为true, 则响应内容中script标签中的脚本内容将被执行
evalResponse - (boolean: 默认为 false) 如果为true, 则整个响应内容将被作为脚本来执行
Request.JSON 专门用于发送和接收JSON格式数据的请求,这里ajax调用后将返回一个json对像
示例:
var jsonRequest = new Request.JSON({
url: "http://site.com/tellMeAge.php",
onComplete: function(person, text){
alert(person.age); //显示 "25 years".
alert(person.height); //显示 "170 cm".
alert(person.weight); //显示 "120 kg".
}
}).get({
‘firstName‘: ‘John‘,
‘lastName‘: ‘Doe‘
});
更多ecstore 问题可联系站长QQ 1611235299
标签:
原文地址:http://www.cnblogs.com/shopextool/p/5297117.html