Send and receive data in same ajax request with jquery
- by Pedro Esperança
What is the best way to send data and receive a response dependent on that data?
Consider the php file used for the request:
$test = $_POST['test'];
echo json_encode($test);
I have tried unsucessfully to achieve this with:
$.ajax({
type: "POST",
dataType: "json",
data: '{test : worked}',
url: 'ajax/getDude.php',
success: function(response) {
alert(response);
}
});