Forum Archive - Juri::base with domains

Juri::base with domains
Apr 12, 2013 5:37 pm by compojoom
Hey guys, I'm the developer of Hotspots : https://compojoom.com/joomla-extensions/hotspots I currently have a client who is using gtranslate PRO and he has problems with my extension. Now what is happening is that when you select a new language -> the domain name changes. Hotspots makes an ajax request to get the data. But because it makes an ajax request to the main domain and not to the subdomain -> the cross domain browser policy comes into place and no request takes place. I use the Juri::base() function to determine the domain name to which to send the request. Normally if you are on example.com -> it will return example.com. If you are on example.com/something -> it will return example.com/something . if you are on de.example.com -> it should return de.example.com . But with gtranslate it returns example.com ... So I though ok, maybe we can modify the javascript to read the window.location and I tried to execute the ajax query directly - it worked and maybe this is a possible solution, but there is another problem. The response to my ajax request is a json object. But in in this case when I send the request through the de.example.com then my response starts with % and ends with <!-- delivered by GTranslate v4.3.3 visit http://gtranslate.net --> This is going to brake the application as it expects a json object. Any ideas/recommendation on what to do? Kind regards, Daniel https://compojoom.com
Re: Juri::base with domains
Apr 13, 2013 10:27 am by Edvard
Hi, I suggest to use relative path when making the request. So instead of JURI::base() use JURI::base(true). If the response is JSON, then you need to use Content-Type: application/json header instead of text/html. Thanks!
Re: Juri::base with domains
Apr 15, 2013 9:05 am by compojoom
Hey Edvard, Thanks for the reply. It seems that the jdocument -> setMimeEncoding function is not working properly and it is not settings the content-type as it should. I used the header("Content-Type: application/json"); function and now it seems to be fine. Regards, Daniel
Re: Juri::base with domains
Apr 16, 2013 8:02 am by Edvard
Thanks!

SIMILAR TOPICS

2 domains how to doFeb 13, 2018 2:59 pmReplies: 1Post by: NECAnGeL
How can i use gtranslte for my domains and sundomainsFeb 3, 2017 8:01 amReplies: 1Post by: johnpham
GTranslate Doesn't Work On My two DomainsNov 12, 2016 12:21 pmReplies: 1Post by: vasnate
how can i use gtranslte for my domains and sundomains??Nov 13, 2016 7:49 amReplies: 1Post by: behnamkkk
2 Domains transfer prior Pro License to Enterprise SubscriptSep 16, 2016 7:12 pmReplies: 1Post by: tuva_kyle

Try GTranslate with a free 15 day trial