gpt4 book ai didi

javascript - 类型错误 : context is undefined in javascript

转载 作者:行者123 更新时间:2023-11-29 21:52:34 24 4
gpt4 key购买 nike

我有以下代码:

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);
});

我在标题中遇到了错误。我做错了什么?

最佳答案

您调用函数 pop_open() 但您需要传递对函数 pop_open 的引用

$('td').hover(pop_open, function() {
// ...
})

关于javascript - 类型错误 : context is undefined in javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28307558/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com