Ajax 调用不成功,但 firebug net 显示 Ok
Ajax call is not successfull but firebug net shows Ok
下面是我的代码。Firebug 显示 200 OK 状态。
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<h1>
question: <br> myquestion33<br>
</h1>
<p id = "comments">
comments <br> <br> <br> <br> test<br> test<br>
</p>
Type your comment here
<div id = "newcommentblock">
<p id = "newComment"> </p>
<form id = "foo" name = "commentbox" action = "#" >
<input type = "text" id ="newComment" name = "newComment">
<input type = "submit" value = "post a comment">
</form>
</div>
<p id = "answerswer">
answer
</p>
<script>
$(document).ready(function(){
$("#foo").submit(function(event){
event.preventDefault();
// $("#newcommentblock").html('<img src="a.gif"/>');
request = $.ajax({
url: "getcomment.php",
type: "POST",
timeout:30000,
dataType: "text",
data:{getquestionid: 33
,
getcomment: "test" } ,
});
alert("inside script");
request.done(function (response, textStatus, jqXHR){
console.log("Hooray, it worked!");
//$("#comments").html(response);
});
request.fail(function (jqXHR, textStatus, errorThrown){
console.error(
"The following error occured: " +
textStatus, errorThrown
);
});
request.always(function () {
});
console.log("hi inside");
});
});
</script>
现在,由于后端的数据库正在用最新值进行更新,并且 firebug 也显示 Ok 状态,但我们无法进入
request.done(function (response, textStatus, jqXHR){
console.log("Hooray, it worked!");
//$("#comments").html(response);
});
任何帮助将不胜感激。 谢谢
好的,这是我的得到评论.php
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL :(");
$selected = mysql_select_db("place",$dbhandle)
or die("Could not select akshat :(");
$getcomment=$_POST["getcomment"];
$getquestionid=$_POST["getquestionid"];
$pkey=rand();
$result = mysql_query("INSERT INTO place_comment (sno,comment) VALUES ('$pkey','$getcomment') ")
or die(mysql_error());
$result1 = mysql_query("INSERT INTO question_comment (q_sno,c_sno) VALUES ('$getquestionid','$pkey') ")
or die(mysql_error());
//fetch tha data from the database
//while ($row = mysql_fetch_array($result)) {
// echo " ".$row{'question'}."<br>";
// echo "hello";
//}
//close the connection
mysql_close($dbhandle);
?>
检查返回的 html 中的语法。我遇到了类似的问题,并且标签中的格式不正确的属性使我的应用程序静默失败。
相关文章:
- ASP.NET网络摄像头显示
- ASP.NET MVC,在文本框旁边显示文本
- 如何将JSON结果设置为'src'共'img'以在ASP.NET MVC4中显示图像
- 如何在asp.net按钮上显示Bootstrap Autocloseable警报消息
- 获取中继器控件ASP.Net中显示的单击项目文本框
- 使用谷歌地图、C#、ASP.net、SQL Server显示带有标记的地图.地图未显示
- 如何在Asp.net标签控件中显示Javascript函数值
- 在asp.net页面中显示javascript执行过程中的加载图标
- 在重定向到 ASP.NET C# 中的另一个页面之前显示客户端脚本警报
- ASP.Net VB - 显示数据折叠样式
- 如何在不使用javascript和asp.net选择dropdownlist值的情况下显示验证
- ASP.NET 显示单选按钮列表和下拉列表的进度条/加载
- 在标签中以 asp.net 显示 jQuery 的结果
- Ajax 调用不成功,但 firebug net 显示 Ok
- Javascript,.NET :显示并使用确定/取消警报
- 验证失败 ASP.NET - 显示的元素会更改可见性
- ASP.NET:显示来自C#代码隐藏的警报
- ASP.. NET -显示一个弹出窗口时,导航远离页面和点击确定去一个特定的页面
- 我应该做什么在vb.net显示我的模态弹出
- 客户端验证会导致以 ASP.NET 显示错误的数据