We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

"Evaluate JS" module is hanging up.

Questions and answers about Plum Fuse+

Moderators: admin, support

Post Reply
anorman728
Posts: 15
Joined: Wed May 10, 2017 12:07 pm

"Evaluate JS" module is hanging up.

Post by anorman728 »

We're going to be need to use an http request in JavaScript in our application, but I can't seem to get it to work.

This is an example of what I'm trying to do in an "Evaluate JS" module:

Code: Select all

function paramJSON(inputJSON) {
    var dumArr = [];
    for (var ind in inputJSON) {
        dumArr.push(ind+'='+inputJSON[ind]);
    }
    returnVal = dumArr.join('&');
    return returnVal;
}

var http = new XMLHttpRequest();
var url = "https://example.com/request.php";
var paramsObj = {
    param1 : "testing",
    param2 : "one two three"
};

var params = paramJSON(paramsObj);

http.open("POST",url,true);

http.setRequestHeader("Content-type","application/x-www-form-urlencoded");

http.onreadystatechange = function() {
    if (http.readyState == 4 && http.status == 200) {
        data = JSON.parse(this.responseText);
        [result] = data.result;
    }
}

http.send(params);
(The [result] towards the end is a variable added with the "+" button in the actual module-- It just assigns the result to a Fuse+ variable.)

When I call the number, it just hangs up when I get to this module. It doesn't give the usual "An error has occurred" message. Another Evaluate JS module works fine, but it just adds two numbers and assigns the result to another Fuse+ variable.

This script works fine when run in Firefox.

Our server also shows no sign that Fuse+ tries to contact it.

Does anybody have any idea what could be causing the problem?

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: "Evaluate JS" module is hanging up.

Post by support »

If you wish to call your REST webservice, you should use the REST module. The evaluate JS method should only be used for handling data within the scope of the application.

After calling your REST webservice with the REST module, you can then use the evaluate JS to manipulate the return data, but you do need to use the REST module to access your webservice.

anorman728
Posts: 15
Joined: Wed May 10, 2017 12:07 pm

Re: "Evaluate JS" module is hanging up.

Post by anorman728 »

Thanks, I think that should work. I see now that I've been using Subdialogs when I should have been using REST modules. (I didn't know that the REST module is basically just an HTTP request.)

Post Reply