Created
September 17, 2014 17:08
-
-
Save webcyou/cb4c1714e94d0d9146ef to your computer and use it in GitHub Desktop.
Ajax Model
This file contains 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
var AjaxTime = 10000; | |
var AjaxPath = { | |
requestFile: "ajaxPath" | |
}; | |
var AjaxController = function(){}; | |
AjaxController.prototype ={ | |
createHttpRequest: function() { | |
try { | |
return newXMLHttpRequest(); | |
} catch(e){} | |
}, | |
ajaxError: function() { return; }, | |
requestFile: function() { | |
var that = this, | |
httpObj = that.createHttpRequest(); | |
var timeout = false, | |
timer =setTimeout(function(){ | |
timeout = true; | |
httpObj.abort(); | |
}, AjaxTime); | |
httpObj.open("POST",AjaxPath.requestFile, true); | |
httpObj.onreadystatechange = function() { | |
if(httpObj.readyState !== 4){ return; } | |
if(timeout) { | |
that.ajaxError(); | |
return; | |
}; | |
clearTimeout(timer); | |
if(httpObj.status == 200){ } | |
} | |
httpObj.send(null); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment