如何在javascript中触发sql查询? [英] how to fire sql query in javascript?

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

问题描述

亲爱的先生,



i想在javascript中点击一个简单的选择查询。



plz帮助。

解决方案

不,你不能。您的客户端脚本无法直接访问数据库。最接近的是通过Ajax调用,但它仍然必须通过像php这样的服务器辅助脚本,它依次处理数据库操作。

Ajax示例[ ^ ]


Javascript是一种客户端语言,意味着它不会访问数据库。



所以你需要使用php或任何服务器端语言来访问数据库。



如果使用ajax,它将从db中获取数据而不刷新页面。


如果要查询的数据不是一个非常庞大的数据然后你可以尝试执行以下操作:



1)创建一个asp文件,它将获取数据并将其写入一个htmltable

2)在父文件中包含该asp文件

3)使用document.getElementByID查询该htmltable以获取您想要的数据



请不要尝试这个非常大的数据查询,因为这会使你的页面变得沉重。您也可以将它用于像主条目这样的表 - 不经常更改


dear sir,

i want to do fire a simple select query in javascript.

plz help.

解决方案

No, you cannot. You client-side script has no access to the database directly. The closest is via Ajax call, but it still has to go through a server-aide script like php which in turns handles the database operation.
Ajax example[^]


Javascript is a client side language means it wont access the database.

So you need to use php or any server side language to access the database.

If you use ajax it will fetch data from db without refreshing the page.


If the data that you want to query is not a very huge data then you can try doing the below:

1) Create an asp file that will fetch the data and write it into an htmltable
2) Include that asp file in your parent file
3) Use document.getElementByID to query that htmltable for the data you want

Please do not try this for very huge data queries as this will make your page heavy. You can also use it for table like master entries - that do not change often


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

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