xrequest.js 717 B

12345678910111213141516171819202122232425
  1. 
  2. function request(paras) {
  3. var url = location.href;
  4. var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
  5. var paraObj = {};
  6. for (i = 0; j = paraString[i]; i++) {
  7. paraObj[decodeURI(j.substring(0, j.indexOf("=")).toLowerCase())] = j.substring(j.indexOf("=") + 1, j.length);
  8. }
  9. var returnValue = paraObj[decodeURI(paras.toLowerCase())];
  10. if (typeof (returnValue) == "undefined") {
  11. return "";
  12. }
  13. else {
  14. return decodeURI(returnValue);
  15. }
  16. }
  17. String.prototype.replaceAll = function (s1, s2) {
  18. return this.replace(new RegExp(s1, "gm"), s2);
  19. }
  20. $.apiroot = "";
  21. $.apiget = function (url,success) {
  22. $.get($.apiroot + url, success);
  23. }