Jquery 移动页面无法打开 php 文件

Jquery mobile page not opening php file

我正在尝试将表单从 jquery-移动页面提交到 php 文件进行处理,但每当我按下提交按钮时,它都会显示一个 "Error Loading Page" 对话框。

我已经尝试查看 w3schools website 表单提交示例,我很确定我的代码是 same.This 是我的代码。

index.html

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Jquery Mobile</title>

<!-- Include meta tag to ensure proper rendering and touch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Include jQuery Mobile stylesheets -->
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

<!-- Include the jQuery library -->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

<!-- Include the jQuery Mobile library -->
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

<style>
  .ui-content {
  margin-top:150px;
  margin-left:500px;
  margin-right:500px;
}

/* For mobile screens */
@media screen and (max-width: 480px) {
    .ui-content{
        margin:0px;
}
</style>
</head>

<body>
<div data-role="page" id="chat">
<div data-role="header"><h1>Welcome to the Streamline Chat App</h1></div>
  <div data-role="main" class="ui-content">
   <h3>Select a username to continue</h3>
    <form method="post" action="login.php">
     <label for="username" >Username:</label>
     <input type="text" id="username" name="username">
     <input type="submit" data-inline="true" value="Submit">
    </form>
  </div>
</div>
</body>
</html>

login.php

<?php
 $username = $_POST['username'];

 echo $username;
?>

我想知道我是否做错了什么。请帮帮我。两个文件都在同一个目录中

我从另一个post那里得到了答案here

只需要在表单标签中添加data-ajax="false"

<form method="post" action="login.php" data-ajax="false">
  <label for="username" >Username:</label>
  <input type="text" id="username" name="username">
  <input type="submit" data-inline="true" value="Submit">
</form>