我想将ajax成功结果对象从一个jquery函数传递给另一个。
这是我的代码:
declare @a table (
id int not null,
dt datetime not null,
val varchar(10) not null
)
insert into @a values (1001, '2015-06-01', 'A')
insert into @a values (1001, '2015-06-30', 'B')
insert into @a values (1001, '2015-07-10', 'C')
insert into @a values (1001, '2015-07-11', 'D')
insert into @a values (1001, '2015-08-01', 'E')
insert into @a values (1001, '2015-08-15', 'F')
insert into @a values (1001, '2015-08-20', 'G')
insert into @a values (1001, '2015-08-20', 'H')
insert into @a values (1002, '2015-08-20', 'I')
insert into @a values (1002, '2015-08-20', 'J')
select sub.id, sub.dt, sub.val, month(sub.dt) as [month]
from (
select id, dt, val, row_number() over (partition by id, month(dt) order by dt desc, val) as rn from @a
) as sub
where sub.rn=1
我的jquery函数是:
courses += '<a id="grid-item" class="dsd col-sm-6 col-md-4 " style="padding:10px; cursor:pointer" onclick="func("+result[i].subcourses+")" >';
但是给了我错误。 result [i] .subcourses是对象类型
我怎么能得到这个......任何帮助表示赞赏。提前谢谢
完整代码:
function func(data)
{
}
答案 0 :(得分:0)
你可以写成value ='“+ JSON.stringify(result [i] .subcourses)+”'............ 如果你想要回JSON,你可以将该字符串转换为JSON.parse(value)。
如果您需要更多帮助,请告诉我