mootools1.2版本中怎么post一个表单呢?

superhasty 2009-03-13 02:36:55
另外,看到网上有文章介绍mootools中可以像下面的代码那样post表单,但我怎么在1.2版本中使用不了(错误消息:Ajax没有定义) ?
是因为1.2版本已经改变了这种操作方式,还是我没有下载相关的插件导致的呢(注:我只下载了Core)?

$("send").addEvent("click",function(){
var url="broadcastmore.aspx?areaid="+$("areaidvalue").value+"&say="+escape($("say").value);
// escape()是处理编码函数,没有它传替中文时会出乱码
new Ajax(url,{method:'post',onComplete:function(){
$("Content").innerHTML=this.response.text;
alert('发表成功!');
}}).request();
});

另外,mootools的代码有点偏大,即使使用精简版的也5、60K,大家都怎么用的呢?
...全文
153 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
e421083458 2012-04-13
  • 打赏
  • 举报
回复
<script type="text/javascript" src="js/mootools-1.2.5-core-nc.js"></script>
<script type="text/javascript">
document.addEvent('domready',function(){
var myElement = document.id('myElement');

var myRequest = new Request({
url: 'getMyText.php',
method: 'post',
onRequest: function(){
myElement.set('text', 'loading...');
},
onSuccess: function(responseText){
myElement.set('text', responseText);
},
onFailure: function(){
myElement.set('text', 'Sorry, your request failed :(');
}
});

document.id('myLink').addEvent('click', function(event){
event.stop();
myRequest.setHeader('enctype', 'application/x-www-form-urlencoded');
myRequest.send('userid=' + (this.get('data-userid')));
});
})
</script>
guohouchang 2009-08-11
  • 打赏
  • 举报
回复
关注了1~
fyjava1984 2009-08-04
  • 打赏
  • 举报
回复
cgisir 2009-07-18
  • 打赏
  • 举报
回复
大概是这样的吧,可以查下手册,还有Request.HTML和Request.JSON方法
new Request({
url: 'http://localhost/some_url'
onComplete: function(xmlHttp){
alert(xmlHttp.responseText
}
}).send("save=username&name=John");

52,798

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧