scripting - How to Implement callback for file downloading? -


i wrote script downloads file web using file url. have activexobject of following type.

var objhttp = new activexobject("msxml2.xmlhttp");   objhttp.open("get", strfileurl, false); 

it works perfect small size file says, file size less 100mb. when try download file size greater 100mb script hanged. tried,

objhttp.open("get", strfileurl, true); 

but in case have implement callback function. don't know how implement callback , use it. can me. using testcomplete 7. script wrote;

var objhttp = new activexobject("msxml2.xmlhttp");    objhttp.open("get", strfileurl, true);    objhttp.onreadystatechange = callback;    objhttp.send();     while((objhttp.readystate != 4) && (objhttp.readystate != 'complete'))     {        delay(100);    }     if(200 != objhttp.status)     {       log.error("the " + strfileurl + " file not found." + " returned status " + objhttp.status);      return;     }   

i don't know how implement callback function. can provide me implementation?

thanks

probably, hanging result of while loop waiting specific value of readystate property. if property never gets 1 of expected values, script work forever.

i think msxml2.xmlhttp object fails load large file, , never sets readystate 1 of values script expects. understand happening, check value property has after long time, enough either file load, or attempt fail (say, 2 hours). if know value readystate property has when downloading fails, can handle in script avoid hanging.

that's hanging itself. cause of file downloading problem. have found page tells problem , suggests setting higher timeouts - take look: http://edgylogic.com/blog/downloading-large-files-vbscript/

the example in vbscript, should easy implement same approach jscript. please note example uses different com object - serverxmlhttp. can read (including differences xmlhttp) here: http://msdn.microsoft.com/en-us/library/ms762278(v=vs.85).aspx

i hope helps.


Comments