• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

jquery or javascript reading database

Hello. I have code in jquery which reads a remote database. I am worried about what could happen if that database for some reason goes down. I was wondering if there is a way to switch to another database if the read from the first one fails? Is there some way to know if the read fails?
1 Solution
As far as I know, jQuery or javascript cannot access database. Server side programming is necessary to connect to database (like asp, jsp, php or coldfusion etc.).

jQuery may trigger an ajax call (or a browser request) to the server which inturn talks to database and returns data.

You can switch to another database if the read form one database fails.
a. check connection for first database, if it fails connect to second database
b. If first database connects and read returns 0 records from database,  connect to 2nd database and read.
you can also use try catch blocks in your server side coding to achieve the same.
onyourmarkAuthor Commented:
Thanks. I meant a jquery ajax call.
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now