Question

When using this below code, i need to call the Transmit_SOAP() function. But it fails to call. Is there any problem?

function sample()
{
 var xmlSoapTemplate;
 xmlSoapTemplate  = new XMLHttpRequest();
 xmlSoapTemplate.onreadystatechange = function () {
 if (xmlSoapTemplate.readyState == 4) Transmit_SOAP()
 };
}

function Transmit_SOAP()
{
alert("Function calls");      
}
Était-ce utile?

La solution

You are missing calls to open() and send(), you don't tell it what URL to use etc.

Here's a rough example:

request = new XMLHttpRequest();

request.open('GET','http://www.example.com/', true);
request.onreadystatechange = function() {
    if (request.readyState == 4) {
        ...
    }
}
request.send();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top