0

私はPhonegapを試していて、htmlで非常にシンプルなアプリを持っています.

<!DOCTYPE html>
<html>
    <title>&nbsp;</title>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
        <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    </head>
    <body>
        <div data-role="page" id="page1">
            <div data-role="header">
                <h1>Trying out Phonegap</h1>
            </div>
            <div data-role="content">
                <h3>Sign in here</h3>
                <form>
                    Username
                    <input type='text' name='username'>
                    Password
                    <input type='text' name='password'>
                    <input type='submit' name='submit' value='Login'>
                </form>
            </div>
        </div>
    </body>
</html>

しかし、フォーム送信の処理方法がわかりません。外部 URL api.myserver.com/signin に直接投稿する必要がありますか?それとも、JQuery を使用してフィールドを API に投稿し、応答に基づいて別のビューに変更する必要がありますか? コメントやコード スニペットは非常に役立ちます。

4

1 に答える 1

2

送信イベントが発生したときに javascript/jQuery を使用してフォームの入力の値を取得し、次に ajax を使用して値をリモート サーバーに送信し、応答を待つ必要があります。

応答に応じて、好きな方法で続行できます。ダイアログの表示、ページの変更など。

于 2013-04-12T00:09:38.300 に答える