如何从URL获取数据包含阿拉伯字符?

时间:2014-05-10 12:57:02

标签: jquery json unicode internationalization blogger

在我的Blogger网站中,我需要从JSON Feed中加载帖子,JSON链接如下所示。

http://technopress-demo.blogspot.com/feeds/posts/default/-/LABEL NAME?alt=json-in-script&max-results=5

这是我用来从上面的网址获取帖子的代码。

$.ajax({url:""+window.location.protocol+"//"+window.location.host
        +"/feeds/posts/default/-/"+LABEL NAME
        +"?alt=json-in-script&max-results=5",
        type:'get',dataType:"jsonp",success:function(data){}

问题在于,当我更改“标签名称”时有一个阿拉伯标签,帖子没有加载。我用英文标签测试它并且工作正常,但我有阿拉伯语问题。我试过这个来解码网址,但它没有用。

$.ajax({url:""+window.location.protocol+"//"+window.location.host
        +"/feeds/posts/default/-/"+encodeURIComponent(LABEL NAME)
        +"?alt=json-in-script&max-results=5",
        type:'get',dataType:"jsonp",success:function(data){}

0 个答案:

没有答案