I have an AJAX request that sends information off to a page with POST, and returns the following:
echo '<tr>';
echo '<td>';
echo $product1;
echo '</td>';
echo '<td>';
echo $code1;
echo '</td>';
echo '<td>';
echo $value1;
echo '</td>';
echo '<td>';
echo $time1;
echo '</td>';
echo '</tr>';
// echo '</table>';
echo 'Your code has been successfully redeemed!';
This is my code on the client-side:
}else{
$('#poo tr:last').after(result);
}
My question is… although this works fine as this is appended on to the end of a table client side, I would also like to pass through another variable to be used in PHP, or more specifically, a database query result that can be used within PHP.
Cant seem to figure out how to output different stuff as it will mess up my current arrangement of just echoing out HTML.
Any ideas?
Thanks! 🙂
You could use a json structure:
and then in jquery access each part.
Note, however, if
$myotherdatais an associative array (or object as we call it in javascript) the alert will simply show[object Object]( which is not an error! reference it’s properties with dot syntax or array syntaxjson.otherdata.keyorjson.otherdata["key"])