相关疑难解决方法(0)

[object Object]是什么意思?

我试图从函数中提醒返回的值,我在警报中得到这个

[对象]

这是javascript代码

<script type="text/javascript">
$(function ()
{
var $main = $('#main'),
    $1 = $('#1'),
    $2 = $('#2');

$2.hide(); // hide div#2 when the page is loaded

$main.click(function ()
{
    $1.toggle();
    $2.toggle();
});

 $('#senddvd').click(function ()
{
   alert('hello');
   var a=whichIsVisible();
   alert(whichIsVisible());
});


function whichIsVisible()
{
    if (!$1.is(':hidden')) return $1;
    if (!$2.is(':hidden')) return $2;
}

 });

 </script>
Run Code Online (Sandbox Code Playgroud)

whichIsVisible是我试图检查的功能

javascript jquery

96
推荐指数
6
解决办法
20万
查看次数

JSON返回[object Object]

我试图从指定的URL返回JSON数据但是当弹出警报时它只显示[object Object](我意识到对象对象实际上并不是错误).我想在警报中吐出位置名称和其他字段.我该怎么做呢?

这是我正在看的JSON的一个例子(完整文件有大约30个帖子)

[
  {
    "m_id": 473644,
    "m_positionName": "Application Monitoring Software Engineer",
    "m_positionLocations": [
      {}
    ],
    "m_active": true,
    "m_description": "Job Responsibilities:\r\n\r\n-Create world class application monitoring tools and dashboards for our health care applications\r\n\r\n-Develop business rules to pro actively identify and re-mediate system-level issues before they occur.\r\n\r\n-Create business intelligence reports for internal and external use as a supplement to software products.\r\n\r\n\r\n\r\nJob Requirements:\r\n\r\n-BS or MS Degree in computer science or any engineering discipline.\r\n-4+ years of experience with Java (or other …
Run Code Online (Sandbox Code Playgroud)

ajax jquery json

8
推荐指数
2
解决办法
4万
查看次数

jQuery $ .get()Array返回[object Object]

test.php包括:

echo json_encode( array(
  array("name"=>"John","time"=>"2pm"),
  array("name"=>"2","time"=>"1242pm"),
  array("name"=>"J231ohn","time"=>"2p213m"),
));
Run Code Online (Sandbox Code Playgroud)

jQuery:

$.get("test.php", function(data) {
  $.each(data, function(n, val) {
    alert(n + ': ' + val)
  });
}, "json");
Run Code Online (Sandbox Code Playgroud)

这是结果:

0: [object Object]
1: [object Object]
2: [object Object]
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

php arrays jquery json

1
推荐指数
1
解决办法
7975
查看次数

标签 统计

jquery ×3

json ×2

ajax ×1

arrays ×1

javascript ×1

php ×1