简体   繁体   English

自动完成搜索,有没有一种方法可以在不使用php的情况下对自动完成搜索进行编码?

[英]Auto-complete search, is there a way to code auto complete search without using php?

I only plan to use html, mysql, javascript and jquery. 我只打算使用html,mysql,javascript和jquery。

I know learning php will be a great help in the future but it will take me too long to learn everything in a week. 我知道学习php在将来会很有帮助,但是一周之内学习所有内容将花费我很长时间。

For the sever side I use servlets.. 对于服务器端,我使用servlet。

Thank you 谢谢

As far as I know, no. 据我所知,没有。 Well, strictly speaking, you don't need PHP, but you will need some server-side technology. 好吧,严格来说,您不需要PHP,但是您将需要一些服务器端技术。

Assuming the data you need to autocomplete exists in mySQL, and you use jQuery.ajax() or similar to get the information on the fly, you still need some data access layer in between, which is where PHP or similar comes in. Of course, if you're accessing data that has been exposed by an API, you might have better luck. 假设您需要自动完成的数据存在于mySQL中,并且您使用jQuery.ajax()或类似数据来即时获取信息,那么您仍然需要介于两者之间的一些数据访问层,这就是PHP或类似数据的来源。 ,如果您要访问API公开的数据,则可能会更好。

MySQL runs on your server, but the browser can't open a socket directly to it to do queries. MySQL在您的服务器上运行,但是浏览器无法直接向其打开套接字进行查询。 See: How to Use Sockets in JavaScript\\HTML? 请参阅: 如何在JavaScript \\ HTML中使用套接字?

So you will need something on the server that talks to MySQL and responds back to your jQuery code. 因此,您将需要在服务器上与MySQL对话并响应jQuery代码的某些东西。 I'm all with you that you don't want to learn PHP. 我和你在一起,不想学习PHP。 If you already know javascript, you can use on the server. 如果您已经了解javascript,则可以在服务器上使用 It has libraries to talk to MySQL: MySQL with Node.js 它具有与MySQL通讯的库: 带有Node.js的MySQL

You won't be able to connect to your mySQL database directly using Javascript running on the client. 您将无法使用客户端上运行的Javascript直接连接到mySQL数据库。 The only possible way I can imagine is using another database system which offers an HTTP-interface (such as Apache Cassandra) or using a plugin for mySQL which does this job (I could not find an officially supported one, maybe you got more luck). 我能想象的唯一可能的方法是使用另一个提供HTTP接口的数据库系统(例如Apache Cassandra)或使用可完成此工作的mySQL插件(我找不到官方支持的插件,也许您有更多的运气) 。 This way, you could query data using Javascript/Ajax directly from your client. 这样,您可以直接从客户端使用Javascript / Ajax查询数据。

But keep attention to security concerns, such as SQL injections or handling of client connections, which gets much more complex if you are not using a middle tier (PHP, nodejs, Java, etc.) running on a web server. 但是请注意安全问题,例如SQL注入或客户端连接的处理,如果您不使用在Web服务器上运行的中间层(PHP,nodejs,Java等),则问题会变得更加复杂。

You have to use any server side technology for autocomplete. 您必须使用任何服务器端技术来实现自动完成。 Without using any server side technology you can't create autocomplete (you can do it by adding some dummy records) 如果不使用任何服务器端技术,就无法创建自动完成功能(可以通过添加一些虚拟记录来完成)

I found third party plug ins to do this 我发现第三方插件可以做到这一点

devbrige, intellesense, jquery auto complete devbrige,智能感知,jQuery自动完成

http://www.techyari.in/2014/04/jquery-autocomplete-ajax-tutorial-j2ee-json-mysql.html http://www.techyari.in/2014/04/jquery-autocomplete-ajax-tutorial-j2ee-json-mysql.html

https://github.com/devbridge/jQuery-Autocomplete https://github.com/devbridge/jQuery-自动完成

though I am still trying to work the codes out 尽管我仍在尝试制定代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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