php - Using ajax to submit a form to update database -


Trying to cross the same hidden data to update your SQL using AJAX. But it is not working and there is no error message too.

HTML

  & lt; Form id = "hidden_form" & gt; & Lt; Input type = "hidden" id = "id_hidden" name = "id_hidden" & gt; & Lt; Input type = "submit" value = "accept" & gt; & Lt; / Form & gt; Submit (function () {$ .ajax ({type: "GET", url: " 

Ajax

  $ (" # hidden_form "). $ ("# Add_success") HTML (data); $ ("#"), "$" ("# hidden"), data: $ ("#happyform"), serialize (), // form elements of the serial . Add_err ") .HTML (" ");}});});  

php

  $ id = $ _GET ['id_hidden']; $ Sql ​​= "Update ProjectMileNeston SET = 1 where id = '$ id'" Accepted; If (mysqli_query ($ conn, $ sql)) {resonant "project approved"; } And {echo mysqli_error (); }? & Gt;  

You are not blocking the default behavior of submitted events before the ambex The request is sent, the form is being submitted and the page is reloaded. Capture

  // Event Object Argument $ ("# hidden_form"). Submit (function (evt) {$ .ajax ({...}) // default behavior evt.preventDefault ();  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -