Prototype ajax 代码例子
728x15 ad here
出自Guoshuang Wiki
直接拿 htm 而不是 xml 解析。问题在于:
- .ie 不能本地调试,必须是 http 环境;
- .1.htm 只能是 utf-8 编码。
<script type="text/javascript" src="prototype-1.6.0.2.js"></script>
<script type="text/javascript">
window.onload = function(){
new Ajax.Updater('test', '1.htm', { method: 'get' });
}
</script>
<body>
<div id="test">123</div>
firefox 代码(textContent)prototype ajax 例子
<script type="text/javascript" src="prototype-1.6.0.2.js"></script>
<script type="text/javascript">
window.onload = function(){
new Ajax.Request('1.xml',
{
method:'get',
onSuccess: function(transport){
//ajax 结果处理
alert(transport.responseXML.getElementsByTagName("title")[0].textContent);
},
onFailure: function(){ alert('Something went wrong...') }
});
}
</script>
<body>
<div id="test">123</div>
