Sha256: a015d660f77cf9f748c483176f38ca20b73e302d49c9172ac41145e0355921ae

Contents?: true

Size: 1.21 KB

Versions: 3

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

3 entries across 3 versions & 1 rubygems

Version Path
nitro-0.17.0 proto/public/js/ajax.js
nitro-0.15.0 proto/public/js/ajax.js
nitro-0.16.0 proto/public/js/ajax.js