Javascript &美元。post不是一项功能;在IBM Watson Assistant聊天机器人中
我试图存储从WatsonAssistantchat收到的JSON值,下面是代码:Javascript &美元。post不是一项功能;在IBM Watson Assistant聊天机器人中,javascript,ibm-cloud,chatbot,watson-assistant,.post,Javascript,Ibm Cloud,Chatbot,Watson Assistant,.post,我试图存储从WatsonAssistantchat收到的JSON值,下面是代码: const element = document.querySelector('.chatElement'); window.watsonAssistantChatOptions = { integrationID: "xx", serviceInstance
const element = document.querySelector('.chatElement');
window.watsonAssistantChatOptions = {
integrationID: "xx",
serviceInstanceID: "xx",
onLoad: function (instance) {
/*
Handler functions able the
*/
function handler(event) {
var response= event.data.output;
***json_response = JSON.stringify(response);***// JSON pack
console.log(json_response);
***$.post("chat/home.html", json_response);***
}
instance.on({ type: "receive", handler: handler });
// Actually render the web chat.
instance.render();
}
};
setTimeout(function () {
const t = document.createElement('script');
t.src = 'https://web-chat.global.assistant.watson.appdomain.cloud/loadWatsonAssistantChat.js';
document.head.appendChild(t);
});
我曾尝试使用$.post存储该变量,并在我的view.py中使用它来填充我的数据库,但在执行代码时收到此错误
$.post不是一个函数
关于它的文档说我必须更改jQuery的源代码,但它实际上不起作用。也许我在JS结构方面失败了。如果有人能帮我改正,那就太棒了。
谢谢 你能链接到文档吗?你在哪里运行上面的代码?您如何接收数据?添加更多细节。我真的没有文档,这就是为什么我如此绝望。我在前端运行了这段代码。我从WA接收JSON格式的数据,这是一个聊天机器人。