Created
April 28, 2013 04:53
-
-
Save QETHAN/5475941 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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