2011-06-07 102 views
0
<script type="text/javascript"> 
function reportPost(args, id) { 
var reason = prompt("Reason"); 
    if (reason == null || reason == "") { 
    return false; 
} 
$.ajax({ 
type: "POST", 
url: "testajax.php", 
data: "reason=" + reason + "&" + args, 
success: function(msg) { 
    var reportSpan = document.getElementById('report' + id); 
     reportSpan.parentNode.removeChild(reportSpan); 
} 
}); 
} 
</script> 

<span id="report<?php echo $pid ?>"><a href="#" onclick="reportPost('post_id=<?php echo $pid ?>', <?php echo $pid ?>);return false;" rel="nofollow"><img src="exclamation.png" alt="Report" /></a></span> 

所有我在ajax.php是:阿賈克斯不想工作

mysql_query("INSERT INTO reports (message) VALUES ('test')"); 

沒有被插入到該表,我連我的信任

+0

應該「testajax.php」爲「/testajax.php」嗎? – Trey 2011-06-07 19:58:02

+2

通常的配方:ff&firebug,啓用NET,查看請求和/或javascript錯誤。 – Wrikken 2011-06-07 19:59:40

+0

返回任何錯誤? – Neal 2011-06-07 20:00:03

回答

0

首先,大家說你在「ajax.php」中有那個命令,但你的腳本是針對testajax.php的。

+0

儘管它被稱爲ajax.php,你也許應該先打開一個數據庫連接,解析你的參數等等。 – Hyperboreus 2011-06-07 20:03:00