我使用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在手機上無法使用。任何想法是什麼問題?
給定鏈路阿賈克斯鉻已經工作.. –