"$.post is not a function" in IBM Watson Assistant chatbot

78 Views Asked by At

I'm trying to storage the value of a JSON I receive from WatsonAssistantchat, here is the code:

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

I've tried using $.post to storage that variable and use it in my view.py to populate my db but I receive this error when I execute my code.

$.post is not a function...

And documentation about it says I have to change the source of jQuery but it doesn't really work. Maybe I 'm failing in JS structure. It would be awesome if someone can help me to correct it. Thanks!

0

There are 0 best solutions below