dongtao5055 2017-02-22 04:27
浏览 192

显示[object Object]数据的值

I got data from third party plugin and I just got [object Object] in javascript. I want to pass it on PHP and show all the values on that [object Object]. How could I to do that ? I already pass it to PHP through GET

I got this [object Object] from this part.

    .attr('title', "Save chart")
    .on('click', function (e) { {
        window.location.href = "temp.php?var=" + data;
.append($('<span>save chart</span>'));

This is my PHP code.


$var = $_GET['var'];



if I do var_dump it still get [object Object] but I want to get the values of that [object Object].

  • 写回答

1条回答 默认 最新

  • drn1008 2017-02-22 04:32

    Your object is being converted to a string. Try this in a browser console to see.

    var a = {}
    a.toString() // this will give you [object Object]

    In your code at this step:

    window.location.href = "temp.php?var=" + data;

    you are converting data from object to string. You need to do this

    window.location.href = "temp.php?var=" + JSON.stringify(data);

    and on PHP part of the code, you will now receive it as string, so you need to do this:

    $var = var_dump(json_decode($_GET['var']));
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路