123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- function HttpClient()
- {
- try
- {
- var objRequest = new XMLHttpRequest();
- //var objRequest = new XDomainRequest();
- if (null != objRequest) this.m_objHttpRequest = objRequest;
- }
- catch (e)
- {
- try
- {
- var objRequest = new ActiveXObject("Msxml2.XMLHTTP");
- if (null != objRequest) this.m_objHttpRequest = objRequest;
- }
- catch (e)
- {
- try
- {
- var objRequest = new ActiveXObject("Microsoft.XMLHTTP");
- if (null != objRequest) this.m_objHttpRequest = objRequest;
- }
- catch (e)
- {
- throw new Error("HttpRequest not supported");
- }
- }
- }
- }
- HttpClient.prototype.send = function (strURL, objData, bAsync, handleASyncHttpResponse)
- {
- if (bAsync)
- {
- this.m_objHttpRequest.onreadystatechange = handleASyncHttpResponse;
- }
- else
- {
- this.m_objHttpRequest.onreadystatechange = null;
- }
-
- this.m_objHttpRequest.open("POST", strURL, bAsync);
-
- this.m_objHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
-
- this.m_objHttpRequest.send(objData);
-
- if (!bAsync)
- {
- if (4 == this.m_objHttpRequest.readyState)
- {
- if (200 == this.m_objHttpRequest.status)
- {
- return this.m_objHttpRequest.responseText;
- }
- else
- {
- throw new Error(this.m_objHttpRequest.status);
- }
- }
- return this._handleSyncHttpResponse();
- }
- }
|