Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ajaxXHR() {
- var xhr = null;
- if (window.XMLHttpRequest || window.ActiveXObject) {
- if (window.ActiveXObject) {
- try {xhr = new ActiveXObject("Msxml2.XMLHTTP");}
- catch(e) {xhr = new ActiveXObject("Microsoft.XMLHTTP");}
- }
- else xhr = new XMLHttpRequest();
- } else return null;
- return xhr;
- }
- function ajaxLoad(req_url, data)
- {
- var xhr = ajaxXHR();
- if (xhr == null) {
- alert("ajaxLoad(): XMLHTTPRequest isn't supported by your browser.");
- exit(); //it will stop the script's execution because exit() isn't recognized by the interpreters.
- }
- xhr.open("POST",req_url,false);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send(data);
- if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) return xhr.responseText;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement