XML and RPC-GoogleMaps/API/doc/APIoverview/06-XMLandRPC-N☆E 学習帳

[ リロード ]   [ ソース ]  [ トップ | 一覧 | 単語検索 | 最新 | バックアップ | ヘルプ ]

Counter: 4703, today: 2, yesterday: 5

XML and RPC

http://www.google.com/apis/maps/docu­mentation/

Version 2 (2006.4)

The Google Maps API exports a factory method for creating XmlHttpRequest objects that work in recent versions of IE, Firefox, and Safari. The following example downloads a file called myfile.txt and displays its contents in a JavaScript alert:

var request = GXmlHttp.create();
request.open("GET", "myfile.txt", true);
request.onreadystatechange = function() {
  if (request.readyState == 4) {
    alert(request.responseText);
  }
}
request.send(null);

The API also exports a simpler method for typical HTTP GET requests called GDownloadUrl that eliminates the need for XmlHttpRequest readyState checking. The example above could be rewritten using GDownloadUrl like this:

GDownloadUrl("myfile.txt", function(data, responseCode) {
   alert(data);
});

前のやり方もまだ利用できるようですが、やっぱこれを使った方がすっきりしますね。

 

You can parse an XML document with the static method GXml.parse, which takes a string of XML as its only argument. This method is compatible with most modern browsers, but it throws an exception if the browser does not support XML parsing natively.

See the GXmlHttp and GXml class references for more information.

Version 1

The Google Maps API exports a factory method for creating XmlHttpRequest objects that work in recent versions of IE, Firefox, and Safari. For example,

var request = GXmlHttp.create();
request.open('GET', "myfile.txt", true);
request.onreadystatechange = function() {
  if (request.readyState == 4) {
    alert(request.responseText);
  }
}
request.send(null);

You can parse an XML document with the static method GXml.parse, which takes a string of XML as its only argument. This method is compatible with all browsers, falling back on a JavaScript XML parser if no native XML parsing facilities are available on the browser. We make no guarantees as to the performance or correctness of this "fallback" parser.

Note that the Google Maps API does not require the use of XML or XmlHttpRequest to function, as it is a pure JavaScript/DHTML API.


上記スクリプトの実行
読み込むファイルは「myfile.txt」ではなく GoogleMaps/API/doc/Examples/16-UsingXML で使った「data.xml」で実行
http://never-ever.info/googlemaps/re­sponsetext.php (別窓)

responseText はファイルの中身を全部ってこと

RPC

Remote Procedure Call
e-Words → http://e-words.jp/w/RPC.html

ネットワーク上の異なるマシンで処理を実行する手続き。