如何在javascript函数中运行sql命令? [英] How to run sql command inside javascript function?

查看:69
本文介绍了如何在javascript函数中运行sql命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何从javascript连接到SQL Server数据库?

如何在javascript函数中运行sql查询?希望你能帮忙。非常感谢。

How can I run sql query inside javascript function? Hope you can help. many thanks.

推荐答案

除非你使用像node.js这样的东西,否则javascript代码会在客户端执行(在用户的浏览器中),因此它无法访问SQL服务器。

Unless you are using something like node.js, the javascript code is executed on the client side (in the user's browser), so it doesn't have access to the SQL server.

您应该在服务器端执行SQL查询(例如用PHP或您在服务器端使用的语言),并在客户端执行Ajax请求。

You should do the SQL query on the server side (e.g. in PHP or the language you use on the server side), and do Ajax requests on the client side.

这篇关于如何在javascript函数中运行sql命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆