此代码假设接受用户值,然后给出相应的警报框,但它不起作用。我可以知道这段代码有什么问题吗?我做了很多谷歌搜索(很多指向这个网站),但我似乎找不到解决方案?请提前帮助和感谢。
索引.html
<html>
<head>
<title>the title</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
function check() {
var one = $('#first').val();
var two = $('#second').val();
var three = $('#third').val();
var four = $('#fourth').val();
$.post("result.php", {
first: one,
second: two,
third: three,
fourth: four
},function(data)
{
if (data=="yay") //for no input
{ alert("yay");
}
else
{
alert("nay");
}
}
}
</script>
</head>
<body>
<form name="form">
<input type="text" id="first">
<input type="text" id="second">
<input type="text" id="third">
<input type="text" id="fourth">
<input type="button" value="get" onclick="check();">
</form>
</body>
</html>
结果.php
<?php
$one = $_POST["first"];
$two = $_POST["second"];
$three =$_POST["third"];
$four = $_POST["fourth"];
if($one > 5)
{
echo "yay";
}
elseif($two > 10 ) {
echo "yay"; }
elseif($three > 15 )
{
echo "yay";
}
elseif($four > 20 )
{
echo "yay";
}
else{
echo "nay";
}
?>