weixin_33738555 2012-11-16 14:47 采纳率: 0%
浏览 19

用JavaScript显示对象

I write a script to make an ajax call here is my code

function ajax_post(obj) {
    obj = '#'+ obj; 

    var formData = $(obj).serializeArray();    

    $.ajax({
        url: '__core/info.php',
        type:'get',
        dataType: 'json',
        data: formData,
        success: function(resp){
            alert(resp);
        }
    })
}

and here is my info.php

$last_Res = theme::get_last_themes_desk(); //$last_Res is an array 
echo(json_encode($last_Res));

but when alert it shows return object object ..... what should i do if datatype is json should i convert it to another format ? $last_Res is an array

  • 写回答

3条回答 默认 最新

  • weixin_33691817 2012-11-16 14:51
    关注

    you haven't posted the json format. usually you can access resp. values like this:

    if the json format is:

    data['index']['subindex1'] = 'value1'
    data['index']['subindex2'] = 'value2'
    

    you can

    alert(resp.index.subindex1);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器