Skip to content

Instantly share code, notes, and snippets.

@edwardrf
Last active December 21, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save edwardrf/6318904 to your computer and use it in GitHub Desktop.
Save edwardrf/6318904 to your computer and use it in GitHub Desktop.
Simple showcase of Jquery ajax call
<html>
<head><title>Test Ajax</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(function(){
$('.run').click(function(){
var buf = [
['0','0','0','0','0','0','0','0'],
['0','A','0','A','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0'],
['0','0','0','0','0','0','0','0']
];
if(a < 5 || a > 0)
buf[1][2] = 'E';
$.get("http://10.0.10.89:3000/?cmd=" + toString(buf), function(data){
console.log(data);
});
});
});
function toString(b){
var result = '';
for(var i = 0; i < 8; i++){
for(var j = 0; j < 8; j++){
result = result + b[i][j];
console.log('i=', i, 'j=', j, 'result=', result);
}
}
return result;
}
function moveLeft(b){
for(var i = 0; i < 8; i++){
for(var j = 0; j < 7; j++){
b[i][j] = b[i][j+1];
}
}
}
</script>
</head>
<a href="javascript:void(0)" class="run">Run</a>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment