87,991
社区成员
发帖
与我相关
我的任务
分享<INPUT name=text class="inp" id="text" size=15 maxLength=40>
<INPUT name=text1 type=text1 class="inp" id="text1">
php的$_POST获取键值区分大小写的??。。。URL改成url就行了,发送的数据键名称是小写的
$string = "text:".$_POST['text']." text1:".$_POST['text1']." URL:".$_POST['url']."\r\n"; function check(form) {
$.ajax({ type: 'POST', data: $(form).serialize()+'&url='+encodeURIComponent(location.href), url: 'xxx.php', dataType: 'html', complete: function (xhr) {
if (xhr.responseText == '1') alert('OK');
else alert(xhr.responseText);
}
});
return false;//////////阻止表单提交
}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
function check(form) {
$.ajax({ type: 'POST', data: $(form).serialize(), url: 'xxx.php', dataType: 'html', complete: function (xhr) {
if (xhr.responseText == '1') alert('OK');
else alert(xhr.responseText);
}
});
}
</script>
</head>
<body>
<form onsubmit="return check(this)">
<INPUT name=text class="inp" id="text" size=15 maxLength=40>
<INPUT name=text1 type=text1 class="inp" id="text1">
<input type="submit" value="submit" />
</form>
</body>
</html>
xxx.php
$text=$_POST["text"];
$text1=$_POST["text1"];
//...其他代码
echo "1";
die();<?php
if(isset($_POST['text'])&&isset($_POST['text1']))
{
$string = "text:".$_POST['text']." text1:".$_POST['text1']."\r\n";
$file = fopen("1.txt", "a");
fwrite($file, $string);
fclose($file);
}
?>
我的PHP是这样写的,这样只能接收到text和text1的数据保存1.txt文件里,location.href怎么接收?