Solved

jQuery and SQL to pull and place random text from database

Posted on 2010-09-02
5
314 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:mikesExpertExchange
  • 2
  • 2
5 Comments
 
LVL 1

Author Comment

by:mikesExpertExchange
Comment Utility
this needs to occur when the page loads. and only needs to do the random select once, not on a timer...
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
Comment Utility
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
<script>
$(document).ready(function() {
    $.get( "page.aspx/randomColum", null, function(data) { $("#here").html(data); } );
});
</script>
<body>
<div id="here"></div>

Open in new window

0
 
LVL 6

Assisted Solution

by:johndoeherty
johndoeherty earned 250 total points
Comment Utility
...and with serverside he means something like

<?

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

?>

Greets
JD
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
Comment Utility
thank you.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
You're welcome! Thanks for the points!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now