I've heard that Opera Mobile is supporting AJAX.
So I've tied to wrote a simple page that uses ... Can anyone tell me what is wrong with this page?
<html>
<head>
<script language="javascript">
<!--
var fname = "nav_test.html";
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else
{
xmlhttp = ne开发者_C百科w 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>
In nav_test.html, which is in the same directory as the file shown above, there is only one line:
<p>test</p>
After loading it with Opera Mobile 11 it displays only "nav_test.html". I've checked and this page works with Nokia N900 default browser. But it doesn't with Midori browser. I have also tested it with Firefox browser on my PC and it works there as well. I wish to be able to run this page under Opera since Opera ca be installed on most of modern mobile phones.
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.
精彩评论