jquery+php的问题
不知道为啥不能提交,关键代码如下:index.php<scriptlanguage="javascript"type="text/javascript"><!--$(fu...
不知道为啥不能提交,关键代码如下:
index.php
<script language="javascript" type="text/javascript">
<!--
$(function() {
$("#submit").click(function(){
var nickname = $("#nickname").attr("value");
var content = $("#content").attr("value");
if(nickname == "" || content == "" || content.length < 8){
alert("请认真填写留言,谢谢!");
return false;
}
var url = "lyb_post.php";
$.post(url, {"nickname":nickname,"content":content}, function(data) {
alert(data);
if(data =="success"){
alert("谢谢您的留言!");
$("#nickname").attr("value", "");
$("#content").attr("value", "");
}
else {
alert("请稍后再提交!");
}
});
});
});
-->
</script>
<td height="20" align="center" valign="bottom" scope="col">
<label></label>
<label>昵称:
<input type="text" name="nickname" id="nickname" />
</label>
<span class="STYLE1"> </span>
</p></td>
</tr>
<tr>
<td height="33" align="center" valign="middle" scope="col">
<label>
<textarea name="content" cols="30" rows="2" class="font13" id="content"></textarea>
</label>
</td>
</tr>
<tr>
<td height="28" align="center" valign="middle" class="STYLE16"><label>
<input type="submit" name="Submit" value=" 发 布 " id="submit"/>
lyb_post.php
if (empty($nickname) || empty($content)) {
echo $nickname.$content;
exit;
}
现在这个post.php中两个变量都为空值,
为啥得不到呢? 展开
index.php
<script language="javascript" type="text/javascript">
<!--
$(function() {
$("#submit").click(function(){
var nickname = $("#nickname").attr("value");
var content = $("#content").attr("value");
if(nickname == "" || content == "" || content.length < 8){
alert("请认真填写留言,谢谢!");
return false;
}
var url = "lyb_post.php";
$.post(url, {"nickname":nickname,"content":content}, function(data) {
alert(data);
if(data =="success"){
alert("谢谢您的留言!");
$("#nickname").attr("value", "");
$("#content").attr("value", "");
}
else {
alert("请稍后再提交!");
}
});
});
});
-->
</script>
<td height="20" align="center" valign="bottom" scope="col">
<label></label>
<label>昵称:
<input type="text" name="nickname" id="nickname" />
</label>
<span class="STYLE1"> </span>
</p></td>
</tr>
<tr>
<td height="33" align="center" valign="middle" scope="col">
<label>
<textarea name="content" cols="30" rows="2" class="font13" id="content"></textarea>
</label>
</td>
</tr>
<tr>
<td height="28" align="center" valign="middle" class="STYLE16"><label>
<input type="submit" name="Submit" value=" 发 布 " id="submit"/>
lyb_post.php
if (empty($nickname) || empty($content)) {
echo $nickname.$content;
exit;
}
现在这个post.php中两个变量都为空值,
为啥得不到呢? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询