jsonp 跨域 能返回数据但 无法返回成功问题

apihandler.ashx?callback=eqfeed_callback:1Uncaught SyntaxError: Unexpected token :

 

 原因在于jsonp传的数据格式不一样.

 解决方法,后端处理json字符串如下:

jsonp(
.... my json ...
)

 如 .net  

string jsonp = context.Request["jsonpcallback"];
string str = "[{\"id\":\"1\",\"name\":\"张三\"},{\"id\":\"2\",\"name\":\"李四\"}]";
string strReturn = jsonp + "(" + str + ")";

 

借鉴自:

http://stackoverflow.com/questions/7936610/json-uncaught-syntaxerror-unexpected-token

posted @ 2016-08-03 20:08  龙鸿轩  阅读(2747)  评论(0编辑  收藏  举报