I am working on a ASP.NET/C# web application. I am writing a Jquery script. I would like to know what is the best way to add data to the script from an SQL database . Here is a quick example showing what I would like to do:
Suppose I have a database like this
Name Color
------------+---------------+
Tom FF0000
Kate 00FF00
John 0000FF
In my script I want to do this:
$(function(){
$('#main').Picture({
colors: {Tom:'#FF0000', Kate:'#00FF00', John:'#0000FF'}
});
});
the colors should be red from the database and not hard-coded.
What is the best way to insert the colors in the correct place in my code? Should I do it in a literal control and inject the script from the code behind?
Another example:
$('#location').html('Here we put the text that I got from the database');
Thank you for any help