Azzyh 0 Newbie Poster

Hi.
Firstly i would like to say hello to everyone on Daniweb.com, im new here.

I am using jQuery and AJAX. And i dont know what possible could be wrong with this i made.

The script i made, should insert data into database through a form.

Let me show you the coding:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
var content = $("#content").val;
$.ajax({
    type: "POST",
    url: "save_comment.php",
    data: "kommentar=" + kommentar, "fID=" + fID,
    success: function(response) {
            if response == 1 {
                $("#response").append("Works!");
            } else {
                $("#response").append("Not Work!");
            }
    }
});
</script>
<div id="response"></div>
<div id="content">
<form action="" method="post">
<textarea name="kommentar"></textarea><br />
<input type="hidden" name="fID" value="<? echo $_GET["id"]; ?>" />
<input id="opret" type="submit" name="submit" value="Opret" />
</form>
</div>

save_comment.php:

<?PHP
include "../tilslut.php";
      if(isset($_POST['submit']))
      {
          $kommentar = $_POST['kommentar'];
	  $fID = $_POST['fID'];
	  $navn = "Azzyh";
          mysql_query("INSERT INTO member_filmcomments (kommentar, fID, navn)
VALUES ('$kommentar', '$fID', '$navn')") or die(mysql_error());
         echo 1;
      } else {
         echo 0;
      }
	  ?>

And ive had tested the save_comment.php script, and it inserts perfectly, but doing this with ajax, it will not work, so something must be wrong.

Thank you in forward!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.