Juri::base with domains
Apr 12, 2013 5:37 pm by compojoom
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
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
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
Apr 16, 2013 8:02 am by Edvard
Thanks!
SIMILAR TOPICS
2 domains how to do | Feb 13, 2018 2:59 pm | Replies: 1 | Post by: NECAnGeL |
How can i use gtranslte for my domains and sundomains | Feb 3, 2017 8:01 am | Replies: 1 | Post by: johnpham |
GTranslate Doesn't Work On My two Domains | Nov 12, 2016 12:21 pm | Replies: 1 | Post by: vasnate |
how can i use gtranslte for my domains and sundomains?? | Nov 13, 2016 7:49 am | Replies: 1 | Post by: behnamkkk |
2 Domains transfer prior Pro License to Enterprise Subscript | Sep 16, 2016 7:12 pm | Replies: 1 | Post by: tuva_kyle |