2013-09-20 4 views
0

Ниже мой код. Firebug показывает 200 OK.Ajax вызов не увенчался успехом, но firebug net показывает 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 = "answer"> 
answer 
</p> 
<script> 
$(document).ready(function(){ 
$("#foo").submit(function(event){ 
event.preventDefault(); 
// $("#newcommentblock").html(&#039;<img src="a.gif"/>&#039;); 
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> 

Теперь, так как база данных в задней части становится обновляется с последними значениями и поджигатель также показывает Ok статус, но мы не можем попасть внутрь

request.done(function (response, textStatus, jqXHR){ 
    console.log("Hooray, it worked!"); 
    //$("#comments").html(response); 
    }); 

Любая помощь будет оценена. спасибо

Ok вот мой getcomment.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); 


?> 

ответ

0

Проверьте синтаксис в ваш HTML вернулся. У меня была аналогичная проблема, и неправильный атрибут в теге выполнял мое приложение без проблем.

Смежные вопросы