My ajax call won't send to php file for it to show on screen. The call is running because i get the "ok" alert but the php page does not show the hello world on the screen
$.ajax({
type: "POST",
url: "test.php",
data: {data: "hello world"},
success: function(){
alert("OK");
}
});
$test = 7;
echo $test;
$data = "";
$data = $_POST["data"];
$request = $data;
print_r($request);
echo $request;
expected: 7hello world actual: 7
You need a callback in your function .. IE
success: function(result){
This will end up with the output of the php
file, and can be used like so:
alert("OK - " + result);
// OR
console.log(result);
// OR
$('#your_element_id').html(result);