Sending values ​​from a form with ajax per item

advertisements

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 = "";
        var url="ajax_pages/remove_answer_field_ajax.php"
        url += '?uuid=' + ans_field_uuid;
        $.get(
        url,
        function (data) {
            result = data;
        }
    )
        .success(function () {
            if (result != "") {
                addTableRow('tb_add_field', result);
                $('#ajaaxDiv').html(result);
            }
        })
        .complete(function () {
            $('#img_create_subcat').hide();
            $('#dialog').dialog('close');
        })
        .error(function () {
            alert('An error has occurred.');
        });
        return false;
    }


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