1
これはプロトタイプサイトのサンプルコードです。プロトタイプのAjaxリクエスト - responseTextだけでなく、トランスポートとは何ですか?
var url = '/proxy?url=' + encodeURIComponent('http://www.google.com/search?q=Prototype');
// notice the use of a proxy to circumvent the Same Origin Policy.
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport) {
var notice = $('notice');
if (transport.responseText.match(/href="http:\/\/prototypejs.org/))
notice.update('Yeah! You are in the Top 10!').setStyle({ background: '#dfd' });
else
notice.update('Damn! You are beyond #10...').setStyle({ background: '#fdd' });
}
});
ajaxリクエストから得られるデータは、transport.responseTextで入手できますが、responseTextだけでなく、トランスポートとは何ですか?
あなたはそうです、それはgetResponseHeaderの代わりにgetHeaderのような少し面白いメソッド名を持つ単純なラッパーです。 – karim79
これは単なる友好的な名前ではありません。これは、JSONのものを追加し、ヘッダーがない場合の動作が異なります。 –