A new get ajax request should be created (even if there is any outstanding ajax request) whenever:-
1) i input any string and press enter (with the help of terminal api).
2) and key-event ajax request when i press ctrl^D ( or C, O,etc). [my code]
But after creating numerous (7 to 8) ajax requests (which are still running), i am not able to create new key-event ajax request. What shall be changed in this code?
<script>
jQuery(document).ready(function($) {
var id = 1;
document.addEventListener("keyup", function(event) {
if(event.ctrlKey) {
switch (event.which) {
case 67:
input_signal='__%ctrl+C%__';
break;
case 68:
input_signal='__%ctrl+D%__';
break;
case 90:
input_signal='__%ctrl+Z%__';
break;
}
/*--------KEY-EVENT AJAX GET REQUEST CODE-------------*/
$('body').ajaxStart(function(){
$.get('/terminal_exec',{input: input_signal}, function(){
//input_signal='process quit');
});
});
console.log( "You pressed "+input_signal );
event.preventDefault()
/*------------------------------------------------*/
}
})
$('body').terminal(function(command, term) {
if (command == 'help') {
term.echo('yoyo man');
} else {
/*--------INPUT STRING AJAX GET REQUEST CODE-------------*/
$.get('/terminal_exec',{input: command}, function(data){
term.echo(data);
});
/*----------------------------------------------------*/
}
}, {
greetings: "HEY",
onBlur: function() {
// prevent loosing focus
return false;
}
});
});