我使用Codeigniter编写了简单的Web应用程序游戏。Ajax请求在不同浏览器上的工作方式不同
这里就是我很困惑。我正在使用Ajax请求,以便能够转到我的不同路由以从位置按钮返回不同数量的黄金。我希望能够在后台有连续的音乐......因此这种方法。
问题是我在Chrome上出现此错误。
XMLHttpRequest cannot load http://www.travterrell.com/ninjagold/Ninjas/cave. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://travterrell.com' is therefore not allowed access.
当我最初发现这个错误,我抬头一看这个问题,我发现我需要插入此代码到travterrell.com的索引文件,因为忍者黄金游戏是我的个人网站
子索引<?php header('Access-Control-Allow-Origin: *'); ?>
我还指示修改我的.htaccess文件到这一点:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ninjagold
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
具体线3条,我重新写了基础。起初这解决了这个问题,但现在我注意到这款游戏在Chrome上无法运行,有时在桌面上运行在Safari上。它适用于Safari移动设备,但单击按钮接收或丢失黄金时的声音效果不起作用。 Chrome在手机上无法使用。任何想法是什么问题?
给定链路阿贾克斯铬已经工作.. –