我们可以通过相同的按钮以相同的形式使用动作和onclick吗?
<form action="welcome.php" method="post"><br/>
<input type="submit" style="height:25px;width:85px;" value="Login" onclick="getdata(n.value,p.value);">
</form>
答案 0 :(得分:0)
您也可以通过以下方式提交forms
:
HTML:
<form id="myform" method="post">
User:<input type="text" name="user"><br>
Password:<input type="text" name="pasw"><br>
<input type="submit" value="Login">
</form>
执行JQuery文件:
$(document).ready(function(){
$('#myform').submit(function(){
var data="user="+$('#user').val()+"&passw="+$('#passw').val();
$.post('welcome.php',data,function(data){
alert(data);//This will show you a response from your welcome.php
});
return false;
});
});
的welcome.php
<?php
$user=$_POST['user'];
$passw=$_POST['passw'];
echo "Welcome $user, your password is $passw";//Your response
?>
(: