Skip to content Skip to sidebar Skip to footer

Sending Values Of A Form With Ajax Via Post

im trying to send values in a form via POST in ajax, how do i capture them in send them, this is wat i have now while in GET function test(ans_field_uuid){ var result =

Solution 1:

since you already use jQuery

$.ajax({
  type: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );
});

data: name and location are your POST variable. You can fetch the POST variable in this example in some.php with

$_POST["name"]

which equals "John"

If you want to receive something then like "Hello". Inside your some.php

echo"Hello";

and it will be send to your ajax function as response in your done function as variable msg

Solution 2:

Documentation for jQuery post

// ...var url = "ajax_pages/remove_answer_field_ajax.php";

$.post( url, "uuid=" + ans_field_uuid, function (data) {
    result = data;
}
// ...

Post a Comment for "Sending Values Of A Form With Ajax Via Post"