12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- function Zid(idstr) {
- try {
- return window.document.getElementById(idstr);
- } catch (e) {
- alert("function Zid:" + e.description);
- }
- }
- function send_request(url, postData, aObjectID) { // ��ʼ����ָ�����?��������ĺ���
- // ��ʼ��ʼ��XMLHttpRequest����
- var http_request;
- if (window.XMLHttpRequest) { // Mozilla �����
- http_request = new XMLHttpRequest();
- if (http_request.overrideMimeType) {// ����MiME���
- http_request.overrideMimeType("text/xml");
- }
- } else if (window.ActiveXObject) { // IE�����
- try {
- http_request = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try {
- http_request = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e) {
- }
- }
- }
- if (!http_request) { // �쳣����������ʵ��ʧ��
- window.alert("���ܴ���XMLHttpRequest����ʵ��.");
- return false;
- }
- http_request.onreadystatechange = getReadyStateHandler(http_request,
- aObjectID);
- // ȷ����������ķ�ʽ��URL�Լ��Ƿ�ͬ��ִ���¶δ���
- http_request.open("POST", url, true);
- http_request.setRequestHeader("Content-Type",
- "application/x-www-form-urlencoded");
- http_request.send(postData);
- }
- function getReadyStateHandler(req, aObjectID) {
- // ����һ������XMLHttpRequestʵ���������
- return function() {
- // ��������״̬�ǡ���ɡ�
- if (req.readyState == 4) {
- // �ɹ������˷�������Ӧ
- if (req.status == 200) {
- var temp = Zid(aObjectID);
- if (temp == null) {
- alert('can not find object');
- } else {
- temp.innerHTML = req.responseText;
- }
- } else {
- // ��HTTP���ⷢ��
- alert("HTTP error: " + req.status);
- }
- }
- }
- }
|