-1

我听说 Opera Mobile 支持 AJAX。

所以我绑写了一个简单的页面,使用......谁能告诉我这个页面有什么问题?

<html>
<head>

<script language="javascript">
<!--
var fname = "nav_test.html";
var xmlhttp;

if (window.XMLHttpRequest)
{
    xmlhttp = new XMLHttpRequest();
}
else
{
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

function mkDoc()
{
if (xmlhttp.readyState == 4)
{
document.open();
document.writeln(fname);
document.writeln(xmlhttp.responseText);
document.close();
}
}

xmlhttp.onreadystatechange= mkDoc;
xmlhttp.open("GET", fname, true);
xmlhttp.send(null);

-->
</script>

</head>
<body />
</html>

在 nav_test.html 中,与上面显示的文件位于同一目录中,只有一行:

<p>test</p>

使用 Opera Mobile 11 加载它后,它只显示“nav_test.html”。我已经检查过,此页面适用于诺基亚 N900 默认浏览器。但它不适用于 Midori 浏览器。我还在我的 PC 上使用 Firefox 浏览器对其进行了测试,它也可以在那里工作。我希望能够在 Opera 下运行这个页面,因为 Opera 可以安装在大多数现代手机上。

4

1 回答 1

1

Of course it supports AJAX. Just run any AJAX framework's showcase on it (such as Ext's showcase).

As for your code, at best download any working example and modify it, if you start learning JavaScript. Don't also write your own AJAX invocation support for various browsers, there's no need for it, because it was already written a thousend times. At best use prototype or jQuery - you can find tons of examples.

于 2012-01-16T14:33:15.153 回答