Welcome Guest, Not a member yet? Register   Sign In
Javascript issue
#1

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

Code:
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:

Code:
function fetch_latest_entries() {

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

        // yadda yadda

        }
    }).request();

}

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

When I execute the above function from username.domain.com, Firebug returns the following:

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

However, when I run the query from domain.com, 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 username.domain.com/fetch rather than domain.com/fetch. But the above .htaccess doesn't allow this.

Any suggestions?


Messages In This Thread
Javascript issue - by El Forum - 05-31-2008, 03:47 PM
Javascript issue - by El Forum - 05-31-2008, 04:23 PM
Javascript issue - by El Forum - 05-31-2008, 04:25 PM
Javascript issue - by El Forum - 05-31-2008, 11:21 PM
Javascript issue - by El Forum - 06-01-2008, 01:16 AM
Javascript issue - by El Forum - 06-01-2008, 04:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB