Juri::base with domains

Popular automatic website translation tool

Juri::base with domains

Postby compojoom » Fri Apr 12, 2013 9:37 pm

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
Code: Select all
<!-- 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
compojoom
 
Posts: 2
Joined: Fri Apr 12, 2013 9:28 pm

Re: Juri::base with domains

Postby Edvard » Sat Apr 13, 2013 2:27 pm

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!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4183
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Juri::base with domains

Postby compojoom » Mon Apr 15, 2013 1:05 pm

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
Code: Select all
header("Content-Type: application/json");   

function and now it seems to be fine.

Regards,
Daniel
compojoom
 
Posts: 2
Joined: Fri Apr 12, 2013 9:28 pm

Re: Juri::base with domains

Postby Edvard » Tue Apr 16, 2013 12:02 pm

Thanks!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4183
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia


  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

2GLux
cron