使用JavaScript / AJAX将数据插入到MySQL数据库 [英] Insert data into MySQL Database using javascript/AJAX
问题描述
我一直使用谷歌地图API的几个领域,用户打算把一些数据做了一个非常简单的页面。它看起来像下面 -
I have made a very simple page using google maps API with several fields where users are going to put some data. It looks like following -
http://aiworker2.usask.ca/marker_field_db.html
我想要做的就是存储使用JavaScript / AJAX数据到MySQL数据库。我已发现,已使用的Jquery几个例子。我很新的这个JavaScript / AJAX / jQuery的平台。现在的问题是 -
What I want to do is store the data into MySQL database using javascript/Ajax. I have found several examples that has used Jquery. I'm very new to this javascript/Ajax/Jquery platform. Now my question is-
- 是否有可能将数据插入到MySQL数据库不使用JQuery?
- 在任何人都可以发送简单的例子或教程的任何一个环节处理这个问题?
在此先感谢。
推荐答案
您的JavaScript运行在客户端(浏览器)。你的MySQL数据库存在于服务器上。
Your JavaScript runs on the client (in the browser). Your MySQL database exists on a server.
总之,在客户端JavaScript无法建立直接连接到MySQL。你需要做一个AJAX请求,它运行了与MySQL进行交互脚本服务器。该脚本可以被写入具有MySQL库的任何语言。
In short, the client-side JavaScript cannot establish a direct connection to MySQL. You need to make an AJAX request to the server which runs a script that interacts with MySQL. The script can be written in any language that has a MySQL library.
下面是一个例子,其中一个AJAX请求时,它调用服务器,这反过来,抓住数据从一个MySQL数据库并返回结果返回给客户端上的PHP脚本:
Here's an example where an AJAX request is made, which calls a PHP script on the server, which, in turn, grabs data from a MySQL database and returns results back to the client:
http://www.w3schools.com/PHP/php_ajax_database.asp
这篇关于使用JavaScript / AJAX将数据插入到MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!