分类: Python/Ruby
2012-12-12 13:55:07
最近在做extjs的项目开发,后台用playframework,前台需要完成一个文件上传的功能,其中涉及到json数据的传输。
我当时直接用了extjs2.2中上传文件的demo来完成这个功能,但是前台在解析json数据的时候,总是出现Uncaught SyntaxError: Unexpected token :的异常,经过调试,也没有发现说后台传输的数据不正确的情况。后来搜了好久,终于发现了原因,原来是我用的extjs代理的问题。原来是demo里面的代理是用了ScriptTagProxy,而ScriptTagProxy是用来解决跨域问题的,如果用了它,返回的数据要按照一定格式来的,然后我改成了HttpProxy,问题就解决了。
具体的可以看下面的官方的文章。
An implementation of that reads a data object from a URL which may be in a domain other than the originating domain of the running page.
Note that if you are retrieving data from a page that is in a domain that is NOT the same as the originating domain of the running page, you must use this class, rather than HttpProxy.
The content passed back from a server resource requested by a ScriptTagProxy must be executable JavaScript source code because it is used as the source inside a