2011-06-07 5 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> 

Tout ce que j'ai en ajax.php est:ajax ne veut pas travailler

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

Rien ne s'ajouté à cette table et je suis connecté moi confiance

+0

est-ce que "testajax.php" devrait être "/testajax.php"? – Trey

+2

La recette habituelle: ff & firebug, activer NET, voir la requête et/ou les erreurs javascript. – Wrikken

+0

des erreurs sont-elles retournées? – Neal

Répondre

0

D'une part, vous avez dit tout vous avez dans "ajax.php" est cette commande, mais votre script cible testajax.php.

+0

Et bien que cela s'appelle ajax.php, vous devriez peut-être d'abord ouvrir une connexion db, analyser vos paramètres, etc. – Hyperboreus

Questions connexes