开发者

Accessing Mysql with JQuery without using php

I'm very new to JQuery, but I was told the one of the cool things about it is you can query a mysql database right from an html page(or in my case a smarty template)with out needing php.

开发者_如何学Python

I have not found any examples of this so I am asking if someone has one? Thanks


Let's hope that you continue not to find any examples of this. By necessity, DB access is kept away from the client. Imagine the mayhem if users could pop open your JS and start firing arbitrary queries/commands at your DB.


This is not possible.

You might be hearing about the HTML5 Web SQL Database standard.


Nope, you're misinformed. This is definitely not possible. You will always need a server-side language to access a remote database, JQuery is not built to do this.

JQuery is able to parse RSS feeds, JSON and XML documents without a server-side language (related questions e.g. here and here). Maybe that is what you mean?


Even if that was possible (it is not), it would be a horrible idea, as the visitor can see and manipulate everything that happens in javascript, so he would get free access to your database.

Some non-relational databases allow JSON queries, though.


It is theoretically possible. You could write a simple MySql remote client in JS, and grant anonymous remote read-only access to certain parts of your database (like the content table, but not tables storing user data). It would be silly, but MySql does have direct remote access functionality. jQuery does not do this though, and trying it out would be a very silly idea, though it could be made sufficiently secure if you really wanted it.


jQuery works client-side, you need a server-side language such as php, asp.net, etc to do that. Simply not possible with jQuery.


You can't do that. To use a database, there needs to be something on the server that connects to the DB server and authenticates.

PHP isn't necessarily needed. You could use Rails, Python, Java...


Some sort of server-side interaction needs to be present.

Smarty's just a template language on top of PHP, so it's entirely possible to create a Smarty template that provides JavaScript-readable data (presumably, JSON or XML) for subsequent AJAX fetching via jQuery.


Maybe you are referring to the client-side database API which is specified by HTML5.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜