1 function WebForm_DoCallback (id, arg, callback, ctx, errorCallback)
3 var myForm = WebForm_GetFormFromCtrl (id);
4 var qs = WebForm_getFormData (myForm) + "&__CALLBACKTARGET=" + id + "&&__CALLBACKARGUMENT=" + escape(arg);
5 // WebForm_httpPost (myForm.serverURL, qs, function (httpPost) { WebForm_ClientCallback (httpPost, ctx, callback, errorCallback); });
6 WebForm_httpPost (document.URL, qs, function (httpPost) { WebForm_ClientCallback (httpPost, ctx, callback, errorCallback); });
9 function WebForm_ClientCallback (httpPost, ctx, callback, errorCallback)
12 var doc = httpPost.responseText;
14 if (errorCallback != null)
15 errorCallback (httpPost.responseText, ctx);
21 function WebForm_getFormData (theForm)
24 var len = theForm.elements.length;
25 for (n=0; n<len; n++) {
26 var elem = theForm.elements [n];
27 if (qs.length > 0) qs += "&";
28 qs += elem.name + "=" + encodeURIComponent (elem.value);
34 function WebForm_httpPost (url, data, callback)
38 if (typeof XMLHttpRequest != "undefined") {
39 httpPost = new XMLHttpRequest ();
42 httpPost = new ActiveXObject (axName);
44 var clsnames = new Array ("MSXML", "MSXML2", "MSXML3", "Microsoft");
45 for (n = 0; n < clsnames.length && httpPost == null; n++) {
46 axName = clsnames [n] + ".XMLHTTP";
48 httpPost = new ActiveXObject (axName);
49 } catch (e) { axName = null; }
52 throw new Error ("XMLHTTP object could not be created.");
55 httpPost.onreadystatechange = function () { if (httpPost.readyState == 4) callback (httpPost); };
57 httpPost.open ("POST", url, true); // async
58 httpPost.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
59 setTimeout (function () { httpPost.send (data); }, 10);