I’m new to rivescript i want to make a synchronous ajax get request in javascript object macros of RiveScript. I will be very grateful if anyone can help. Thanks
Asked
Active
Viewed 359 times
3
-
This question does not involve the Chat Bot language AIML, but instead the chat bot language RiveScript? These are two different languages. Can you explain the link with AIML? – A. Kootstra Jan 12 '17 at 06:33
1 Answers
3
This is how you do it. Note that the ajax call is asynchronous.
+ hello
- <call>sendData</call>
> object sendData javascript
var xhr = new XMLHttpRequest();
xhr.open('GET', 'myservice/username?id=some-unique-id');
xhr.onload = function() {
if (xhr.status === 200) {
alert('User\'s name is ' + xhr.responseText);
}
else {
alert('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();
return "Done.";
< object

rodrigoap
- 7,405
- 35
- 46