How can I pass global variables into a function?

Is it possible to pass variables into an onReadyStateChange function for and XMLHTTP object?

  • Whenever I try to add variable parameters or even add () to the function it stops working. The code I am talking about is xmlhttp.onreadystatechange = function

  • Answer:

    The reason that wouldn't work is because the value you set for xmlhttp.onreadystatechange has to be a function. If you have function() or function(arg1, arg2), it wouldn't work because the value would be the value returned by the execution of the function. Try xmlhttp.onreadystatechange = function (){ function(arg1, arg2);}

Abi Raja at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.