博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

mootools 1-4 ajax

Posted on 2011-11-07 10:41  迷梦江南  阅读(224)  评论(0编辑  收藏  举报

很久没有用过mootools,以前用的是1.1,现在升级到1.4了。下载新版下来发现AJAX的实现方法都变了,做个demo留个记号。

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>AJAXTest1--requestText</title>

    <script src="http://www.cnblogs.com/mootools/mootools-core-1[1].4.1-full-nocompat.js" type="text/javascript"></script>
    
    <script type="text/javascript">
    window.addEvent('domready',function(){
        $('btnSent').addEvent('click',function(){
            var url='ajaxtest.aspx?v='+escape($('txtValue').value);
            var myRequest = new Request({method: 'post', url: url,onComplete:showMsg});
            myRequest.send('v='+escape($('txtValue').value));  
        });
       function showMsg(requestText){
           $('divRebackMsg').innerHTML=requestText;
       }
    });
    </script>
</head>
<body>
    <input id="txtValue" type="text" />
    <input id="btnSent" type="button" value="发送" />
    <div id="divRebackMsg"></div>
</body>
</html>

在后台page_load里输出“Hello,Mootools !”