Kyle Dunne Kyle Dunne - 7 months ago 29
SQL Question

Update MySQL with .html() in JQUERY/AJAX

I have some buttons people can click on and when they click on them it gets me what they clicked on as well as their comment. I usually just pass it on to another page with

$_GET
but I have a
textarea
on this one without a form. How can I use something like below to update a table:

function person_submit() {
var Name = (".name").html();
var Job = (".job").html();
var PickComment = ("comment").val();
}


The mysql update statement is usually something like this in php

UPDATE table
SET name = ?, job = ?, comment = ?

Answer

Use ajax to resolve this issue :

var Name = (".name").html();
var Job = (".job").html();
var PickComment = ("comment").val();

$.ajax({
url: "test.php",
data : {
   name : Name,
   job : Job,
   pickComment : PickComment
 }
 }).done(function() {
   //Do something
 });

More informations here