| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1170 人关注过本帖
标题:dojo.Post提交数据,火狐提交不了,似乎是在按了button之后执行了默认行为, ...
取消只看楼主 加入收藏
于奎星
Rank: 2
等 级:论坛游民
帖 子:14
专家分:21
注 册:2009-9-19
结帖率:66.67%
收藏
已结贴  问题点数:20 回复次数:1 
dojo.Post提交数据,火狐提交不了,似乎是在按了button之后执行了默认行为,但是我明明禁止了。
rt
程序代码:
<body>

<center>
<form id="registForm" method="post">
<table>

    <tr>
        <td><label for="name">手机号:</label></td>
        <td><input dojoType="dijit.form.TextBox" type="text" id="name" name="name"/></td>
    </tr>
    <tr>
        <td><label for="nickname">昵称:</label></td>
        <td><input dojoType="dijit.form.TextBox" type="text" id="nickname" name="nickname"/></td>
    </tr>
    <tr>
        <td><label for="password">密码:</label></td>
        <td><input dojoType="dijit.form.TextBox" type="password" id="password" name="password"/></td>
    </tr>    
    <tr>
        <td><label for="password-2">确认密码:</label></td>
        <td><input dojoType="dijit.form.TextBox" type="password" id="password-2"name="password-2"/>    

    
        </td>
    </tr>
    <tr>
        <td><label for="email">e-mail:</label></td>
        <td><input dojoType="dijit.form.TextBox" type="text" id="email" name="email"/></td>
    </tr>
</table>
<div id="passWdError" class="error">&nbsp;</div>
<button dojoType="dijit.form.Button" id="formBtn" onclick="sendForm()">提交</button>
</form>
</center>


<script type="text/javascript">    

function sendForm()
{
    if(event && event.preventDefault) 
    {
        //阻止默认浏览器动作(W3C)  
        event.preventDefault();
        event.stopPropagation();
    } 
    else 
    {
        //IE中阻止函数器默认动作的方式   
            window.event.returnValue = false; 
        window.event.cancelBubble = true;  
        }
     
    var datatopost=
    {
        "name":""+document.getElementById('name').value,
        "nickname":""+document.getElementById('nickname').value,
        "password":""+document.getElementById('password').value,
        "email":""+document.getElementById('email').value
    };
            
        var kw = 
        {
            postData:dojo.toJson(datatopost),
            url: "http://localhost:8080/mm/rest/register",    //表单要提交到的URL
            handleAs:"json",  //返回值的处理方式
            headers: {"Content-Type": "application/json; charset=utf-

8","Accept":"application/json"},
            load: function(response)
            {
                alert("Response from server:" + response.id

+"-"+response.privacy_policy);                
            },
            error: function(error)
            {
                alert("An error occurred:"+error);
            },
            timeout:5000//超时时间
        };
        dojo.xhrPost(kw);
}
</script>
</body>
</html>

请问这样有问题吗,该怎样解决?
搜索更多相关主题的帖子: button center method 
2012-07-07 10:51
于奎星
Rank: 2
等 级:论坛游民
帖 子:14
专家分:21
注 册:2009-9-19
收藏
得分:0 
回复 3楼 coretear
非常感谢,问题解决了。顺便再问一下,UC7.x在适应屏幕模式下是不是不支持javascript?因为我发现在此模式下我的代码没执行。不知道你了解否
2012-07-07 18:48
快速回复:dojo.Post提交数据,火狐提交不了,似乎是在按了button之后执行了默认 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020371 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved