Created
October 8, 2015 15:05
-
-
Save SeavantUUz/49a30fdfe06073a2060c to your computer and use it in GitHub Desktop.
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
function createXHR(){ | |
if (typeof XMLHttpRequest != "undefined"){ | |
return new XMLHttpRequest(); | |
} | |
else { | |
throw new Error("No XHR object available"); | |
} | |
} | |
// 所有的send从这里走 | |
function send(method, url, data){ | |
var xhr = createXHR(); | |
xhr.open(method, url, true); | |
if (method.toLowerCase() === 'get'){ | |
data = null; | |
} | |
else { | |
data = JSON.stringify(data); | |
} | |
xhr.send(data); | |
} | |
test_start = function(){ | |
send('post', '/', {"command": "START", "msg": {"wrapper": "okCoinTicker", "processes_num": 1, "actors_num": 1}}); | |
window.location.replace('/success'); | |
}; | |
test_stop = function(){ | |
send('post', '/', {"command": "STOP", "msg": {"wrapper": "okCoinTicker", "processes_num": 1, "actors_num": 1}}); | |
window.location.replace('/success'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment