4

I'm still pretty new to AJAX. We have a MySQL database that stores addresses for people who register with the site. We then use those stored addresses to create markers on a Google Map (API v3) through a JSON query. The problem is, that's pretty slow, and limited in the number of queries we're allowed. So we've created fields in the database to store the latitude and longitude that is being called by JSON.

Through each pass of the loop, the numbers can be retrieved through

result[0].geometry.location.lat() result[0].geometry.location.lng()

How do I take those numbers and store them into their empty fields in the database?

4

2 に答える 2

4

Javascriptはクライアント/ブラウザ側で実行されます-mysql-server/databasesへのアクセスを許可することはお勧めできません。

そのためにサーバーサイドロジック(php)を使用するだけです。

これは、AJAXとPHPを介してデータを取得するW3の例ですが、更新に変更するだけです。

http://www.w3schools.com/php/php_ajax_database.asp

于 2012-08-02T15:56:39.620 に答える
2

javascriptを使用してサーバーにデータを送信できますが、データベースシステムと対話するにはライブラリが必要です。そのため、サーバーでは通常、そのデータを処理し、コマンドを送信してデータベースに保存します。PHPには、MySQLのサポートが組み込まれているため、mysql_XXXXのように、またはPDOオブジェクトを介してデータベースに接続するための関数とオブジェクトがあります。

http://php.net/manual/en/book.pdo.php

于 2012-08-02T15:57:02.657 に答える