Given the following jquery :
$.post(path, {one:'alex', two:'thomas'}, function (response) {
alert(response);
});
And the following PHP :
<?php
$first = $_POST['one'];
echo $first;
?>
How do I get it to return a response?
It works fine if I send just one variable:
$.post(path, 'one=alex', function (response) {
alert(response);
});
Thanks
Use json.
$response = array(
'first' => $response1,
'second' => $response2
);
echo json_encode($response);
$.post(path, 'one=alex', function (response) {
response = JSON.parse(response );
alert(response.first);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.