Javascripts and databases

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsteph
    New Member
    • Oct 2006
    • 71

    Javascripts and databases

    I have a javascript that scrolls through a series of "headlines" - essentially key points for the month or week for our customers, or key changes to our website, prices, etc.

    right now the sctipt essentially has an array of strings that gets read into a function and changed into a line of html code.

    myArray =[['link','text'],[..],..]

    I would like to have this linked to a database, so that it will read the link and text fields from a table - this will make things easier to update.

    Could anyone help me with the code I need to link the database through javascript? I've done it in vbscript before, but never javascript.

    Thank in advance for any help you can offer.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    JavaScript cannot access a database, but you could use Ajax (see links in Offsite Links thread) which makes a request to a server-side script.

    Comment

    • rsteph
      New Member
      • Oct 2006
      • 71

      #3
      So then I could use a server-side script to access a database, and then use Ajax to link between that include, and the javascript?

      Originally posted by acoder
      JavaScript cannot access a database, but you could use Ajax (see links in Offsite Links thread) which makes a request to a server-side script.

      Comment

      • epots9
        Recognized Expert Top Contributor
        • May 2007
        • 1352

        #4
        Originally posted by rsteph
        So then I could use a server-side script to access a database, and then use Ajax to link between that include, and the javascript?
        ajax == javascript

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by rsteph
          So then I could use a server-side script to access a database, and then use Ajax to link between that include, and the javascript?
          In a way, yes, but not quite. The Ajax code that you would use is actually just Javascript code (as pointed out by epots9), but it does allow you access to the response from the server. This, you could then use in your non-Ajax Javascript functions/code.

          Comment

          Working...