JQuery properties - problem
I am using this plugin: jQuery.i18n.properties
I put this code:
/* Do stuff when the DOM is ready */
jQuery(document).ready(loadMessage);
/*
* Add elements behaviours.
*/
function loadMessage() {
jQuery("#customMessage").html("test");
jQuery.i18n.properties({
name:'up_mail_messages',
path:'https://static.unifiedpost.com/apps/myup/customer/upmail/upmail_messages/',
mode:'both',
language:'en',
callback: function() {
var messageKey = 'up.mail.test';
//alert(eval(messageKey));
jQuery('#customMessage').html(jQuery.i18n.prop(messageKey));
}
});
}
I don't understand why, in the customeMessage div it prints:
[up.mail.test]
instead of value:
up.mail.test = messages downloaded from en
Can anyone show me where I am going wrong? I spent about two hours on this without finding a clue ...
Many thanks.
Ps: here is the post file: https://static.unifiedpost.com/apps/myup/customer/upmail/upmail_messages/up_mail_messages_en.properties
EDIT: After testing locally, everything works well. But if the message files are located on a different host (like in the example above) it seems like it fails ... It would be nice if someone can confirm this ...
EDIT 1: This doesn't work because inside the js script there is an ajax call to read the message files. Well, as you probably know, cross-domain XMLHttpRequest is not allowed in ajax due to browser restrictions.
a source to share
May I disturb you and check my suspicion?
Replace the first line with the following:
$(document).ready(function() {loadMessage()});
Also, I note that https://static.unifiedpost.com/apps/myup/customer/upmail/upmail_messages/up_mail_messages.properties is returning a 404 error and the en version works well. Is this intentional?
a source to share
I dont know you are returning the server, so in php I just repeat something like this:
$arg = 'up.mail.test=messages loaded from en';
exit($arg);
then js:
.......
callback: function() {
var messageKey = up.mail.test;
//alert(eval(messageKey));
jQuery('#customMessage').html(jQuery.i18n.prop(messageKey));
}
I received the following: [messages loaded from en]
. Is this what you want?
a source to share