Asynchronouns mode about XMLHTTP

xiaoxiao2021-03-06  68

I recently found Microsoft.xmlhttp very easy. Want to implement a desktop client application in Delphi, using XMLHTTP4.0 in MS XML 4.0 to implement XML HTTP communication. Unfortunately, the asynchronous mode in JavaScript is actually achievable in Delphi. . Alas, depressed ah description in MSDN: Note that onreadystatechange is designed for use in scripting environments and is not readily accessible in Microsoft Visual Basic or C see an instance in JavaScript, it is really flexbilityvar gThreadRequest = null; var gRequestXML = '<. XML> ... ';

Function asyncDataExchg () {if (gthreadRequest == null) asyncRequest ("http: // ...", grequestXML);}

function AsyncRequest (url, xmlstr) {gThreadRequest = new ActiveXObject ( "Microsoft.XMLHTTP"); gThreadRequest.Open ( "POST", url, true); gThreadRequest.onreadystatechange = handleChange; gThreadRequest.Send (xmlstr);}

Function Handlechange () {if (gthreadRequest! = null && gthreadrequest.readystate == 4) VAR Xmlret = gthreadRequest.ResponseText; // do something ... gthreadRequest = null;}}

转载请注明原文地址:https://www.9cbs.com/read-90622.html

New Post(0)