Page 1 of 1

"Evaluate JS" module is hanging up.

Posted: Fri May 19, 2017 3:18 pm
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?

Re: "Evaluate JS" module is hanging up.

Posted: Mon May 22, 2017 9:22 am
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.

Re: "Evaluate JS" module is hanging up.

Posted: Mon May 22, 2017 10:44 am
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.)