更新:我尝试了一个没有“beforeContentUpdate”部分的脚本版本,这个脚本返回以下 JSON
{"COLUMNS":["TNAME","TBRIEF","GAMEID","TITLEID","RDATE","GNAME","PABBR","PNAME","RSCORE","RNAME"],
"DATA":[["Dark Void","Ancient gods known as 'The Watchers,' once banished from our world by superhuman Adepts, have returned with a vengeance.",254,54,"January, 19 2010 00:00:00","Action & Adventure","X360","Xbox 360",3.3,"14 Anos"]]}
但是,使用包含“beforeContentUpdate”的脚本不会返回任何内容。我用Firebug看tooltip生成的div的内容,是空白的!
你好,我想知道是否有人可以帮助我解决这段代码第 14 行的语法错误:
调试器在 var json = eval('(' + content + ')');
missing ) in parenthetical
// Tooltips for index.cfm
$(document).ready(function()
{
$('#catalog a[href]').each(function()
{
$(this).qtip( {
content: {
url: 'components/viewgames.cfc?method=fGameDetails',
data: { gameID: $(this).attr('href').match(/gameID=([0-9]+)$/)[1] },
method: 'get'
},
api: {
beforeContentUpdate: function(content) {
var json = eval('(' + content + ')');
content = $('<div />').append(
$('<h1 />', {
html: json.TNAME
}));
return content;
}
},
});
});
});
最佳答案
你忘了一个
+
应该是:
var json = eval('(' + content + ')');
关于JavaScript 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2954098/