![]() |
Javascript issue - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Javascript issue (/showthread.php?tid=8794) |
Javascript issue - El Forum - 05-31-2008 [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 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() { 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? Javascript issue - El Forum - 05-31-2008 [eluser]Bramme[/eluser] 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: http://jimbojw.com/wiki/index.php?title=Introduction_to_Cross-Domain_Ajax Might be an interesting read for you ![]() Javascript issue - El Forum - 05-31-2008 [eluser]Nial[/eluser] I was hoping there'd be a simple solution as username.domain.com is not actually a physical subdomain, but rather sends the user to domain.com/users/view. 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 http://ellislab.com/forums/viewthread/61799/P15/. This could lead you in some correct direction. have a good day !!! Javascript issue - El Forum - 06-01-2008 [eluser]Crimp[/eluser] Use JSONP? Javascript issue - El Forum - 06-01-2008 [eluser]Bramme[/eluser] [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! |