文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>mootools提交表单

mootools提交表单

时间:2007-08-09  来源:linxh

 

<script src="js/mootools.v1.11.js" language="JavaScript"></script>

<script>
function handleFun(res)
{
    alert(res);
}

function showResponse(res)
{
    alert(res);
}
function ajaxSubmit(){
    var postArgs = $('form1').toQueryString();
    alert(postArgs);
    new Ajax('test.php',{data:postArgs,onComplete:handleFun}).request();
}

function ajaxSubmit2(){
    var postArgs = $('form1').toQueryString();
    alert(postArgs);
    $('form1').send({onComplete:showResponse,data:postArgs});
}
</script>
<form action="test.php" id="form1">
<input name="user_name" />
<input name="user_id" />
<input type="button" onclick="ajaxSubmit();" value="xxx"/>
<input type="button" onclick="ajaxSubmit2();" value="yyy" />
</form>

      说明:   $()函数相当于js的document.getElementById();   toQueryString()函数是得到form中提交元素的字符串。   注意这两个例子区别:
    用1时无需在form中指定action,而必须指定Ajax中的url  2则必须指定form中action,而无需指定Ajax中的url

另外在 test.php 中接受参数一律用 $_POST[''] 接受即可。

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载