Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php JQuery位置正确吗?_Php_Jquery_Mysql - Fatal编程技术网

Php JQuery位置正确吗?

Php JQuery位置正确吗?,php,jquery,mysql,Php,Jquery,Mysql,这是我第一次使用jquery,我认为它似乎不起作用。这里有一些代码 <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script type = "text/javascript"> function insertComment(comment, assign

这是我第一次使用jquery,我认为它似乎不起作用。这里有一些代码

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type = "text/javascript">
    function insertComment(comment, assignment, pid){
     alert(comment);
     alert(assignment);
     alert(pid);
     var url = "addComment.php";


    $.post(url, {comment: comment, assignment: assignment, pid: pid}); 
}


</script>
这里是addComment.php

<?php

include ("viewComments.php");


//Connection string to get to database
$host = 'host'; 
$user = 'user'; 
$password = 'pw'; 
$dbh = new mysqli($localhost, $user, $password, "kao17_CS242Portfolio");

//Prpared statement for user inpur, prevent sql-injection attacks
$stmt = $dbh->prepare("INSERT INTO tbl_Comment (comment, project_title, parent_comment_id) VALUES (? , ? , ?)");
$stmt->bind_param('ssi', $prevComment, $prevAssignment, $parentID);

$prevAssignment = $_POST['assignment'];
$parentID = $_POST['pid'];
$prevComment = profanityCheck($_POST['comment']);




    $stmt->execute();
 ?>

它什么也没做。如果它真的去了addComments,有没有其他地方需要提醒?或者我只是使用了错误的post,SQL应该是正确的。我知道我得到了正确的参数警报信息,任何帮助都将是巨大的,谢谢

您可以在对$的调用中添加回调函数。post:


然后在执行SQL语句后,在PHP中添加'OK'。如果在运行insertComment时在警报框中显示OK,则说明调用已成功,并且PHP存在任何问题。

检查firebug/控制台以查看任何错误。。任何404?检查您的浏览器控制台。你应该在那里看到一个请求。在大多数浏览器上,它是F12键。
$.post(url, {comment: comment, assignment: assignment, pid: pid}, function(data, textStatus, jqXHR) {
  alert(data);
});