Sha256: b5a3ad72e3110dcee33c3c3896de22f422e665fa2e26aab2661c6075c8fa7047

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

function ajax_get(url) {
  req = xml_http_request_object();
  req.open("GET", url, false); 
  req.send(null);
  return req.responseText;
}

function ajax_async_get(url, callback) {
  req = xml_http_request_object();
  req.open("GET", url, true); 

  req.onreadystatechange = function() {
		if (req.readyState == 4 && req.status == 200) {
    	return callback(req.responseText);
		}
	}

  req.send(null);
}

function ajax_post(url) {
  req = xml_http_request_object();
  req.open("POST", url, false); 
  req.send(null);
  return req.responseText;
}

function ajax_async_post(url, callback) {
  req = xml_http_request_object();
  req.open("POST", url, true); 

  req.onreadystatechange = function() {
		if (req.readyState == 4 && req.status == 200) {
    	return callback(req.responseText);
		}
	}

  req.send(null);
}

function xml_http_request_object() {
  var req = false;
  try {
    req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {   
      req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
			try {
				req = ActiveXObject("Msxml2.XMLHTTP.4.0");
			} catch (e) {
				req = false;
			}
    }
  }

  if (!req && typeof XMLHttpRequest!='undefined') {
    req = new XMLHttpRequest();
  }

  return req;
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.16.0 examples/ajax/public/js/ajax.js
nitro-0.13.0 examples/ajax/public/js/ajax.js
nitro-0.15.0 examples/ajax/public/js/ajax.js
nitro-0.14.0 examples/ajax/public/js/ajax.js
nitro-0.17.0 examples/ajax/public/js/ajax.js