我正在尝试使用 jQuery 发送表单的数据。但是,数据没有到达服务器,它继续使用该GET
函数来获取 ./?page=game&mode=search&type=private 并且它一直在获取该页面并且不会停止获取它。你能告诉我我做错了什么吗?
php:
if (isset($_GET['type'])) {
$type = $secure->clean($_GET['type']);
} else {
$type = '';
}
if ($type == 'private') {
if ( isset($_POST['submit'])) {
$name = $secure->clean($_REQUEST['name']);
$checkuser = $db->fetch("SELECT * FROM accounts WHERE name == '$name''");
if ($checkuser) {
$data ='<h1> The user you searched for does not exist. </h1>
<a class="goback message" href="#">Continue</a>';
}
} else {
$checkMatch = $db->query("SELECT * FROM accounts WHERE `id` = '".$account['id']."'");
while ($info = mysql_fetch_array($checkMatch)) {
$status = $info['status'];
$gameid = $info['gameid'];
}
if($status = 'NULL') {
$data ='<h1> Who do you want to battle against? </h1><br />
<form action="" method="post" id="form-pb" name="pb" target="_self" >
USERNAME:<input name="name" type="text" size="40" maxlength="40" />
<input name="submit" type="submit" value="Search"/>
</form>
<a class="goback" href="#">Cancel</a>';
}
}
echo $data;
exit;
}
Java脚本
case 'submit':
$.post('./?page=game&mode=search&type=private', $("#form-pb").serialize(), function(data){
var $response=$(data);
var error = $response.filter('h3').text();
$('.search').html(data);
if(!error){
match = setInterval(function(){
if(!$('.search').length){
$('#main_container').prepend('<div id="popup"><div class="opacity"></div><div class="search"></div></div>');
}
$('.search').load('./?page=game&mode=search&type=private', function(){
var meta = $('#stopMe').attr('content'); var meta = $('#stopMe').attr('content');
if(meta){
meta = meta.split("URL="), meta = meta[1];
window.location = meta;
}
});
},1000);
}
});
break;
形式是
<form action="" method="post" id="form-pb" name="pb" target="_self" >
USERNAME:<input name="name" type="text" size="40" maxlength="40" />
<input name="submit" type="submit" value="Search"/>
</form>