如何使用jquery alon将数据提取到html网页的下拉列表中 [英] How to fetch data to a drop down list in a html webpage using jquery alon

查看:80
本文介绍了如何使用jquery alon将数据提取到html网页的下拉列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jquery单独将数据提取到html网页的下拉列表中?



我知道可以使用php,ajax等完成但是我想要仅使用jquery从MySQL数据库中获取数据。

解决方案

下次开始,在发布问题之前拍摄谷歌。



您可以使用 jQuery.ajax [ ^ ]&这里有样本 [ ^ ]。自定义它。


这是不可能的,因为如果你考虑它,你会发现,如果是这样的话,你的数据库服务器必须可以公开地访问查询,这是一个非常不安全的配置。



您必须拥有浏览器与之通信的服务器端应用程序(例如PHP脚本,ASP.net Web应用程序等) ,并且只将正确的查询发送到本地隔离的数据库服务器。



浏览器和服务器之间的任何通信,不涉及页面刷新(或HTML5 web)套接字)根据定义是AJAX,并且在最初加载页面后填充下拉列表肯定是一个AJAX调用。


这里我给你一个想法,

首先你应该有restfull服务,然后你可以使用json电话呼叫该服务。



见以下代码:



How to fetch data to a drop down list in a html webpage using jquery alone?

I know it can be done using php, ajax, etc but I want to fetch data from MySQL database using jquery only.

解决方案

Next time onwards, Shoot Google before posting questions.

You could use
jQuery.ajax[^] & here a sample[^]. Customize it.


It isn't possible to do this because if you think about it, you'll see that if it were, your database server would have to be publically accessible to queries, and that is a ridiculously insecure configuration.

You must have a server side application (e.g. PHP scripts, an ASP.net web app, etc) which the browser communicates with, and which sends only the correct queries to a locally insulated database server.

Any communication between a browser and server that doesn't involve a page refresh (or HTML5 web sockets) is AJAX by definition, and populating a dropdown list after a page is initially loaded will definitely be an AJAX call.


Here i am giving you an idea ,
First you should have restfull service and then you can call that service using json call.

see following code:


这篇关于如何使用jquery alon将数据提取到html网页的下拉列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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