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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何让企业微信机器人实现消息汇总整合
    • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
    • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
    • ¥15 TLE9879QXA40 电机驱动
    • ¥20 对于工程问题的非线性数学模型进行线性化
    • ¥15 Mirare PLUS 进行密钥认证?(详解)
    • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
    • ¥20 想用ollama做一个自己的AI数据库
    • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
    • ¥15 请问怎么才能复现这样的图呀