如何在HTML5游戏中从另一个页面获取字符串?

时间:2016-12-15 13:42:01

标签: javascript html5 flash xmlhttprequest jquery-animate

我正在尝试在Flash中创建一个HTML5游戏,但是我很难从另一个页面获取一个字符串(所以,所有页面的内容都是一个字符串,让我们说我想要来自{{{}的内容1}}),在不同的域上。那么当我的游戏在浏览器中运行时,如何从其他页面获取数据?到目前为止,我尝试使用XMLHttpRequest。我在Flash项目的第一层编写了以下代码:

example.com

到目前为止,这是我的代码,但它无效。在浏览器控制台中,我收到以下错误:url = "http://www.example.com/"; GetCustomerInfo(); var xmlHttp = null; function GetCustomerInfo() { xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = ProcessRequest; xmlHttp.open( "GET", url, true ); xmlHttp.send( null ); } function ProcessRequest() { if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) { if ( xmlHttp.responseText == "Not found" ) { //action } else { //action } } }

如果我收到一种完全不同的解决方法,我不介意,这与我使用的方法不同。

0 个答案:

没有答案