第一種 也是最古老的一種方法之一
from 表單直接提交數據到php文件里
action為路徑
<form method="post" action="./index.php"> <input name="username" placeholder="用戶名" type="text" > <input name="password"placeholder="密碼" type="password"> <input value="登錄" type="submit"> </form>
data為要傳遞的參數
$.post(路徑,{"data":data},function(a){
alert(a);
},"json");
jq提交方式
$.ajax({ url:"./index.php", type:"post", data:{username:username}, dataType:"json", success:function(a){ alert(a) }, error:function(e){ alert("錯誤"); } });