Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery not adding the values to database, readystate=0, and status=0
    text
    copied!<p>My script does not seem to be working. Every time i try to use the form i've get the error with readystate=0, and status=0. Any help will be appreciated. I've got the following form:</p> <pre><code>&lt;form action="" method="post" &gt; &lt;input type="text" name="name" id="tekst"/&gt;&lt;br/&gt; &lt;input type="text" name="name" id="autor"/&gt;&lt;br/&gt; &lt;input type="submit" name="&lt;?php echo $id; ?&gt;" value="Send" id="submit"/&gt; &lt;/form&gt; &lt;div class="response"&gt;&lt;/div&gt; </code></pre> <p>the values from input fields are then processed by the following code:</p> <pre><code>$("input#submit").click(function(){ var id = $("input#submit").attr("name"); var autor = $('input#autor').val(); var tresc = $('input#tekst').val(); $.ajax({ type: "POST", url: "add_comment.php", data: {id: id, autor: autor, tresc: tresc}, success: function(data){ $(".response").text(data); }, error:function(xhr,err){ alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status); alert("responseText: "+xhr.responseText); } }); }); </code></pre> <p>Here is my add_comment.php:</p> <pre><code>&lt;?php $id = $_POST['id']; $autor= $_POST['autor']; $tresc = $_POST['tresc']; if(isset($id) &amp;&amp; isset($autor) &amp;&amp; isset($tresc)){ include("db/connection.php"); $zapytanie= "INSERT INTO komentarze(id_ref, autor, tresc) values ('$id', '$autor', '$tresc')"; $wynik = $db-&gt;query($zapytanie); echo "Added"; }else{ echo "Problem"; } ?&gt; </code></pre> <p>EDIT: id_ref is not auto_increment field. The script is running on the localhost</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload