简体   繁体   中英

using sql scripts in javascript

我可以使用javascript使用sql脚本将项目保存到数据库吗?

Not directly, unless you are working with a client-side database . However, you can hook JavaScript up with a server-side script (whichever backend you'd prefer) using XMLHttpRequest .

You really don't want to do this. If you store SQL in your client-side javascript, you are exposing the details and structure of your database to an attacker. Creating an AJAX method to execute passed in javascript without creating a hole and attacker could use to perform SQL Injection attacks would be quite difficult.

As in Javascript on the browser? No, you can't.

Hypothetically you could use AJAX techniques to push SQL commands through a server layer and thence to the database but you really, really wouldn't want to since that would be an unholy mother of all security risks.

不,您必须使用某种服务器端处理语言,例如php,asp...。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM