我有一款HTML5游戏在桌面平台上运行良好,我使用ajax发送参数和接收数据。
事实上,一切都很好,但在cocoon中,在cocoonjs中根本不起作用,我不知道为什么,jQuery是支持的,理论上一切都应该没问题。有人知道为什么不工作这个代码吗?
提前感谢。
$.ajax({
type: 'GET',
url: this.baseURL+'/getScores.php',
data: {
'theGame': '1',
'theOrder': 'ASC'
},
fail: function(msg){
alert(msg);
}
});
我也在尝试这个代码(不工作在cocoonjs)
$.getJSON( STK.root.urlBase+"/getScores.php",
{ theGame: "1", theOrder: "ASC" }
)
.done(function(data) {
//DO STUFF
})
.fail(function( jqxhr, textStatus, error ) {
console.log( "Request failed: " + err );
});
好吧,一切都是CORS的东西,我修复了这个头在php文件中接收/发送数据:
header("Access-Control-Allow-Origin: *");