Better approach for displaying two php var with jquery ajax <p>I'm getting two random values from a table. The values are in the same row.</p> <pre><code>&lt;?php $result = mysql_query("SELECT * FROM people ORDER BY RAND() LIMIT 1", $connection); $row = mysql_fetch_array($result); echo $row["name"]; echo $row["surname"]; ?&gt; </code></pre> <p>And I want to display these two values at different div's on my html page by using jquery ajax functions.</p> <pre><code>$(function() { $("#sentence-form").submit(function() { $.ajax( { type : "GET", url : "newperson.php", success : function(response) { $("#top-container").append(response); /* Both name and surname */ } }); }); }); </code></pre> <p>The problem is seperating two values to display different in div's. I tried to use two ajax calls and I sended a boolean data to php to use with an if statement. So one of the ajax calls displays name and the other one displays surname. But because of randomization its a bit complicated to find surname of a name. </p> <p>Could you advise me a better approach?</p>