有人可以告诉我为什么会收到此错误,为什么我的代码无法正常工作吗?谢谢!
var jquery = document.createElement("script");
bbbfooter.appendChild(jquery);
jquery.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js");
var byefooter = document.createElement("script");
bbbfooter.appendChild(byefooter);
var byefooters = document.createTextNode("function byeFooter(){$('.bbbfooter').animate({ bottom: -100, duration: 500, queue: false });} $('.clickx').on('click', byeFooter);");
byefooter.appendChild(byefooters);
bbbfooter在我的代码中已经声明过
答案 0 :(得分:1)
脚本加载需要时间,您正在尝试立即使用。
您将不得不使用// load jquery
var run_if_jquery_is_defined = function (callback) {
if ( typeof $ != 'undefined' ) {
callback();
} else {
setTimeout(function () { run_if_jquery_is_defined(callback); }, 50);
}
};
run_if_jquery_is_defined( function () {
// your code that needs jquery
} );
来检查$的定义时间,然后才使用jQuery来完成所需的操作。
import asyncio
import websockets
import json
msg = \
{
"jsonrpc" : "2.0",
"id" : 9929,
"method" : "public/auth",
"params" : {
"grant_type" : "client_credentials",
"client_id" : "xxxxxxxxxxxxxxxxxx",
"client_secret" : "xxxxxxxxxxxxxxxxx"
}
}
async def call_api(msg):
async with websockets.connect('wss://testapp.deribit.com/ws/api/v2') as websocket:
await websocket.send(msg)
while websocket.open:
response = await websocket.recv()
# do something with the response...
print(response)
asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))