Yi's profile无尽愿PhotosBlogListsMore Tools Help
    9/9/2009

    Ext传递多层参数中的汉字问题

        ExtJS库利用request方法提交异步HTTP请求,它的params参数可以传递一个平面的JSON对象,将形如{Fa:v1,Fb:v2}的参数对象展开为Fa=v1&Fb=v2这样的POST参数表。不过,这个params参数并不接受类似{Fa:{Name:"Mike"}}这样的复合JSON对象。Ext虽然有一个decode函数可以将任意层次的JSON对象转化为字符串,但经过测试,它竟然会将字符串值中的两个汉字编码为三个Unicode字符。。。于是不得已只能自己来处理了。
        原理也不复杂——利用JSON格式支持\uXXXX形式的Unicode编码的功能,将汉字转化为合法的JSON代码,搞定:)
     
        PARAM样例:
          UIID=(2142638864)&act=PEV&data={event:"FVCHG",field:"NativePlace__Lo",value:"\u5317\u4EAC"}&callback=_FdChg&id=1

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://creationzy.spaces.live.com/blog/cns!F7BAA280447BB7D7!655.trak
    Weblogs that reference this entry
    • None