weixin_33698043 2015-06-03 05:20 采纳率: 0%
浏览 25

jQuery Mobile:对话问题

So, I'm working on a website, and I am trying to implement a dialogue page that asks for a passcode and then submits it to a php script to validate it. I have successfully implemented that part of the code, but another problem has risen. Whenever I close my dialogue box, whatever is in the input somehow gets inserted into the url of the page as if posting an ajax request! This is a serious problem because it reveals the entered passcode.

Here's mycode:

<div data-role="page" data-dialog="true" id="LoginForm">
    <div data-role="header">
        <h1>Enter Passcode!</h1>
    </div>

    <div data-role="main" class="ui-content">
        <p style="text-align: center; padding: 5px; background-color: #110000;" id="LoginFormTitle">Please enter passcode for current war!</p>
            <form data-ajax="false" method="POST">
                <div class=\"ui-field-contain\">    
                    <input type="password" name="LoginPasscode" id="LoginPasscode" placeholder="Enter Passcode for War here"/>

                    <input type="button" value="Submit" onclick="login()" />
                </div>
            </form>
            <div data-role="popup" id="LOginResultMsg" data-overlay-theme="b" style="padding: 15px;"></div> 
    </div>

    <div data-role="footer">
        <h1>Please gain war code from Slayer.  Thanks!</h1>
    </div>  
</div> 

Please help! Thanks.

EDIT: Here's the login function:

function login()
{   
var serverurl = getSiteURL() + "validateWarPass.php";

var passcode = {WarPass: $("#LoginPasscode").val()};


$.ajax({
    type: "POST",
    url: serverurl,
    data: passcode,
    success: function (response) {//response is value returned from php (for your example it's "bye bye"
        if(response == 1)
        {
            sessionStorage.canViewAddWar = true;
            ShowAttacksScheduled();
            showWarStatus();
            $.mobile.changePage( localStorage.SelPage, { transition: "slideup", changeHash: false });
        }
        else
        {
            sessionStorage.canViewAddWar = false;
            $("#LoginFormTitle").html("<span style=\"color: red\">Invalid Passcode!</span>");
        }
    }

});

$("#LoginPasscode").val("");

}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题