Javascript and database connection

Is it possible for javascript to access the database directly? I feel that my question is rhetorical because it is a security issue. But is this even possible?

+4
source share
6 answers

It is possible!
with the new html5 function, js can connect via WebSql. live example: http://html5demos.com/database
The syntax is similar to all other sql shells:

var db = openDatabase('mydb', '1.0', 'my first database', 2 * 1024 * 1024); db.transaction(function (tx) { tx.executeSql('CREATE TABLE foo (id unique, text)'); }); 

currently supported by chrome, safari and opera
here is a tutorial: http://html5doctor.com/introducing-web-sql-databases/

+6
source

Is it possible for javascript to access the database directly?

No. Set up the server side of the script that will talk to the database and then invoke this script using AJAX.

+3
source

Depends on which database you want to use.

CouchDB is an HTTP address, so it can be removed from JS. http://couchdb.apache.org/

+2
source

Not from the browser. Javascript can be used on the server to configure server-side functionality.

+1
source

Yes it is.

I don't know more about this, but javascript can connect to the database using ADODB.Connection.

0
source

http://www.daniweb.com/web-development/php/threads/197091/update-mysql-table-using-javascript You need to look into the jQuery.ajax function, this will send / receive information from the PHP document.

What you need to do is set up a PHP document that will process the form as if it was submitted via http, or by setting the action in the tag.

Then you need to do the same function:

0
source

Source: https://habr.com/ru/post/1346342/


All Articles