日期:2014-05-16  浏览次数:20637 次

异步返回的是一个对象格式的字符串,为什么alert时不是显示object呢?
alert出来的内容为:
{"a":"1","b":"2"}

为什么要在这函数里面转一下才是对象呢?

function data_back(response)
{
response=(new Function('return'+response))();
return response;
}

------解决方案--------------------
function data_back(response)
{
response=(new Function('return '+response))();
return response;

少了个空格
------解决方案--------------------
因为 你一般http协议 默认返回的 text/html格式 就是 字符串
------解决方案--------------------
response=(new Function('return'+response))();
return response;

这个也可以是

eval("("+response+")")

总之后天输出后前台接受到的是字符串,需要转化成js对象,所以必须有一个eval的过程