I have a simple AJAX request which sends data to a PHP and the PHP sends some sucess data back to the AJAX as usual. For example
var firstvalue = xxx;
var secondvalue = xxx2;
AJAX
$.post("some.php",{value1 : firstvalue, value2 : secondvalue}, function(data){
if(data) {
alert(data);
} else {
alert("An error occurred.");
}
});
PHP (some.php)
$id = S_GET['someid'];
$impdata = $_GET['somegettabledata']
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
if (value1 === value2) {
/*
This is my problem I want to echo id and impdata
but I don't know how to pass both of them
*/
echo "...";
} else {
echo "Error.";
}
So how can I have both the id and impdata in that data sent back from PHP? Sorry if this comes across as stupid.
Many Thanks
In PHP:
In javascript you will need to parse the json string:
JSON parser can be found at the bottom of the following page: http://www.json.org/js.html