开发者

jQuery properties - problem

I use 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() {
        jQ开发者_开发技巧uery("#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 do not understand why, in the customeMessage div it prints out:

[up.mail.test]

instead of the value of it:

up.mail.test=messages loaded from en

Can anybody show me where i am wrong? I;ve spent about two hours on it without finding any clue...

Many Thanks.

Ps: here is the message file: https://static.unifiedpost.com/apps/myup/customer/upmail/upmail_messages/up_mail_messages_en.properties

EDIT: After testing locally, all works good. But if the messages files are located to another host (like in the above example) it seems that it fails...It would be nice if anyone can confirm this...

EDIT 1: It does not work because inside the js script there is an ajax call to read the messages files. Well, as you probably know, Cross-Domain XMLHttpRequest Calls are forbidden in ajax due to the browsers restrictions.


Could I trouble you and test a suspicion of mine?

Replace your first line with:

$(document).ready(function() {loadMessage()});

Also, I note that https://static.unifiedpost.com/apps/myup/customer/upmail/upmail_messages/up_mail_messages.properties returns a 404 error, while the en version works well. Is this intentional?


i don't know what is you server return, so in php i just echo something like this :

$arg = 'up.mail.test=messages loaded from en';
exit($arg);

then the js :

.......
callback: function() {
    var messageKey = up.mail.test;
    //alert(eval(messageKey));
   jQuery('#customMessage').html(jQuery.i18n.prop(messageKey));
}

i got this : [messages loaded from en] . is this what you want ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜