CodeIgniter Forums
Javascript issue - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Javascript issue (/showthread.php?tid=8794)

Javascript issue - El Forum - 05-31-2008

In this thread I asked about setting up 'fake' subdomains for users. Here's the .htaccess I wound up with:

RewriteEngine on

# Prevent infinite loop
rewriteCond $1 !^index.php/user/show/

RewriteCond %1 !^www$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.database\.com
RewriteCond %1 !^www$ [NC]
RewriteRule (.*) index.php/user/show/%1/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt|css|js|img|uploads|avatars)
RewriteRule ^(.*)$ /index.php/$1 [L]

This works well. Except for when I come to carry out an Ajax query (I use the Mootools library).Basically, I have a function which generates an Ajax request:

function fetch_latest_entries() {

   new Ajax('fetch', {
    method: 'get',
        onComplete: function() {

        // yadda yadda



This works great when I call it from However, I assign each user on my site their own subdomain, like so: Within cPanel I've setup * to point towards{username}.

When I execute the above function from, Firebug returns the following:

Quote:[Exception... "'Permission denied to call method' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no]

However, when I run the query from, it works fine. A little snooping around on Google has led me to believe that this is because the XMLHttpRequest considers a subdomain and a domain to be different locations. To solve this I imagine I have to send the request to rather than But the above .htaccess doesn't allow this.

Any suggestions?

Javascript issue - El Forum - 05-31-2008

Your assumptions about the xmlhttprequest are right. A subdomain and normal domain are indeed two different locations and for security reasons, ajax can't make a call from one to the other.

However. I read smth today that might do the trick for you. Sucks it's slipping my mind atm though. Flickr uses it to make calls to their api.

When googling, I stumbled upon this:

Might be an interesting read for you Wink

Javascript issue - El Forum - 05-31-2008

I was hoping there'd be a simple solution as is not actually a physical subdomain, but rather sends the user to

Javascript issue - El Forum - 05-31-2008

[eluser]Sarfaraz Momin[/eluser]
I did this actually but for categories and I did not use .htaccess for it since it complicates the whole structure. Instead I used CI routes to achieve the task. Please check the post here This could lead you in some correct direction.

have a good day !!!

Javascript issue - El Forum - 06-01-2008


Javascript issue - El Forum - 06-01-2008

[quote author="Crimp" date="1212322567"]Use JSONP?[/quote]

That's what it was called! I believe it's mentioned in the link I posted a few posts up too. However, I like Sarfaraz Momin's idea too!