sách gpt4 ai đã đi

jQuery .load() không thành công

In lại 作者:行者123 更新时间:2023-12-05 09:18:02 31 4
mua khóa gpt4 Nike

我正在尝试运行在以下链接中找到的答案: Asynchronously Load the Contents of a Div

但是当我这样做时,我会遇到我不太理解的错误。

我的代码:

$(tài liệu).ready(hàm() {
$("#first").load(function() {
$("body").append($("
").attr({
id: "second"
}).text("Second"));
$("#second").load(function() {
$("body").append($("
").attr({
id: "third"
}).text("Third"));
});
});
});


<đầu>




First



我从 Chrome 返回的错误非常广泛。但这里是亮点:

Uncaught TypeError: a.indexOf is not a function
at r.fn.init.r.fn.load (jquery-3.2.1.min.js:4)
at HTMLDocument. (temp.html:6)
at j (jquery-3.2.1.min.js:2)
at k (jquery-3.2.1.min.js:2)

Bạn có ý tưởng nào không?

1 Câu trả lời

此错误可能是由 jquery 事件别名引起的,例如 .error,.load hoặc .unload。自 jQuery 1.8 以来,这些已被弃用。您需要将它们替换为 .on() 以注册监听器。示例:

$(window).load(function(){
...
});

变成:

$(window).on('load', function(){
...
});

所以尝试使用 .on()

关于jQuery .load() 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45974680/

31 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com