我有以下代码:
function pop_open () {
var contents = $( this ).html() ;
if (contents.match("^http")) {
console.log('contents',contents);
$that = $( this );
$url = contents;
$.ajax({
type:"POST",
url: "Ajax/getHtml",
context: $that,
data: { u : 'http://stackoverflow.com' },
dataType: 'html',
error: function(jqXHR, textStatus, errorThrown) {
console.log('error');
console.log(jqXHR, textStatus, errorThrown);
}
}).done(function(html) {
$link = $('<a href="myreference.html" class="p1" data-html="true" data-bind="popover">');
$link.data('content', html);
$that = $(this);
// Trigger the popover to open
$link = $(this).find('a');
$link.popover("show");
});
}
}
$('td').hover( pop_open(), function() {
$link = $that.find('a');
$link.popover("hide");
$that.html($url);
});
我收到标题中的错误。我做错了什么?
答案 0 :(得分:2)
您调用函数pop_open()
但需要传递对函数pop_open
$('td').hover(pop_open, function() {
// ...
})