我想从我的服务器接收纯文本(或任何文档)作为字符串变量,例如在警报中显示它我尝试了这个解决方案
wordsurl = "http://alpha/test";
function ButtonClicked() {
showsentence(wordsurl)
}
function httpGet(theUrl)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
return xmlhttp.responseText;
}
}
xmlhttp.open("GET", theUrl, false );
xmlhttp.send(); // NS_ERROR_FAILURE is here
}
function showsentence(generatorurl) {
alert(httpGet(generatorurl));
}
but i'm getting NS_ERROR_FAILURE. Which is referring to the send.
Here is a
如何从服务器获取纯文本?
Here is
啊,现在我明白了..
您应该从以下位置提供 html 页面:http://
服务器..不是文件file://
因此设置一个简单的http服务器,并尝试再次访问它。您也可以从同一服务器提供它,就像您的应用程序逻辑一样
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)