jQuery and SQL to pull and place random text from database

How would one use jQuery to randomly select a column from a table in an SQL database that would then be shown to the user on a page?
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?
leakim971Connect With a Mentor PluritechnicianCommented:
if you do it only one time, at page load you should be able to do that on the server side directly.

else of course your answer is ajax : http://api.jquery.com/jQuery.get/

you need to create an .net page returning the random column
$(document).ready(function() {
    $.get( "page.aspx/randomColum", null, function(data) { $("#here").html(data); } );
<div id="here"></div>

Open in new window

Michael SterlingWeb Applications DeveloperAuthor Commented:
this needs to occur when the page loads. and only needs to do the random select once, not on a timer...
Mike DConnect With a Mentor Solution ConsultantCommented:
...and with serverside he means something like


echo "<script>";
echo "var =" . $my_rand_nr;
echo "</script>";


Michael SterlingWeb Applications DeveloperAuthor Commented:
thank you.
You're welcome! Thanks for the points!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.