这是来自原型(prototype)站点的示例代码。
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,那么传输是什么?
最佳答案
实际上,这是一个 Ajax.Response目的。链接页面列出了所有其他属性。它是实际 XMLHttpRequest 对象的包装器。
关于javascript - 带有原型(prototype)的 Ajax 请求 - 如果不仅仅是 responseText,什么是传输?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1037483/