javascript - Updating database after a drag and drop operation -


After the drop down, I want to update a database, from that drop operation I get a variable that is database I have an ID of the line I need to find and update. Is it possible to put php code in my JavaScript drop function so that it can be used to make this database query? Or any other idea how can I get it? My work in javascript:

  function drop (ev) {ev.preventDefault (); Var data = ev.dataTransfer.getData ("text"); // variable data is the variable that I need to find and update that specific row in my database var addthis = document.getElementById (data); Var parent = document.getElementById (ev.target.id); Parent.style.backgroundColor = "#E9E9E9"; Var todelete = parent.firstChild; Parent.appendChild (shared); Parent.removeChild (todelete); }  

You need to use it to

Include a first jquery plugin in your page like this:

  & lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" & gt; & Lt; / Script & gt;  

Then edit your drop () form:

  & lt; Script & gt; Function Update () {// Your Code Here // $ to save $ azx $ AJAX ({type: 'POST', url: 'update.php', data: {data: data}, success: function () {alert ('update');}}); } & Lt; / Script & gt; You then need to create a file  update.php , in that file you can use data variable:  
 < Code> & lt ;? Php $ data = $ _POST ['data']; // $ to save data as you like? & Gt;  

Comments