要是在php返回一个
echo { name:"yxl", age:4};在jQuery处理的时候,怎么写呢?是下面这样写吗?
$.get('.php',{:''},F ,'json'); //★★这里我直接写'json' 对吗?
function F(result , success , xhr)
{
alert( result.name ); //★★这里是这样调用吗?
}Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
后端返回的是一个json字符串,而不是对象。使用JavaScript原生的JSON.parse方法把json字符串解析为对象,就可以用了。