Skip to content

Instantly share code, notes, and snippets.

@SeavantUUz
Created October 8, 2015 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeavantUUz/49a30fdfe06073a2060c to your computer and use it in GitHub Desktop.
Save SeavantUUz/49a30fdfe06073a2060c to your computer and use it in GitHub Desktop.
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