Skip to content

Instantly share code, notes, and snippets.

@QETHAN
Created April 28, 2013 04:53
Show Gist options
  • Save QETHAN/5475941 to your computer and use it in GitHub Desktop.
Save QETHAN/5475941 to your computer and use it in GitHub Desktop.
/**
* ajax方法
*/
define(function(require, exports) {
exports.get = function(url, succCall) {
if (url == undefined) {
console.log("请求地址缺失!");
return;
}
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200 && typeof succCall === "function") {
succCall.call(xhr, xhr.responseText);
}
};
xhr.open("GET", url, true);
xhr.send();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment