0

In this line of code:

var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function () {
    if(ajax.readyState == 4) {
        function() {document.getElementById(f3).innerHTML = ajax.responseText};
    }
};

This line:

...
        function() {document.getElementById(f3).innerHTML = ajax.responseText};
...

is getting an error that the Function must be named.

This is the full scope of the code:

var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function () {
    if(ajax.readyState == 4) {
        function() {document.getElementById(f3).innerHTML = ajax.responseText};
    }
};
var urlToOpen = "~.$_tFileName.qq~?pg=admin_main&load=subscriptionAdmin&view=setANewVar&n=" + f1 + "&v=" + f2 + "~.$SessId.q~" + "&stopIEcache=" + Math.floor(Math.random()*99999);
ajax.open("GET", urlToOpen, true);
ajax.send(null);

The Tilde Marks (~) are because this file is built with Perl syntax. the output is a full url... for example:

https://www.google.com/search?pg=admin_main&load=subscriptionAdmin&view=setANewVar&n= of course it is not on Google... just put that url instead of the real one.

Can you tell me what is wrong with that line? and how I can make it work?

Thank you. Rich

1 Answer 1

2

Remove function() it's unnecessary to have it there

var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function () {
    if(ajax.readyState == 4) {
        document.getElementById(f3).innerHTML = ajax.responseText
    }
};
var urlToOpen = "~.$_tFileName.qq~?pg=admin_main&load=subscriptionAdmin&view=setANewVar&n=" + f1 + "&v=" + f2 + "~.$SessId.q~" + "&stopIEcache=" + Date.now();
ajax.open("GET", urlToOpen, true);
ajax.send(null); // PS. you can also remove null -> ajax.send();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.