Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery .keyup() function

Tags:

jquery

php

I'm not receiving any output from this code. What could be the error.

terminal.html

<html>
<head>
<link href="/css/webterminal.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.5.2.js"/>
<script type="text/javascript">
function shell_execute(str) {     
  $.ajax({
    url: 'exec.php',
    dataType: 'text',
    data: {
      q: str
    },
    success: function (response) {
      $('#txtOut').append(response);

  });
}
</script>
</head
<body">
    <div class="container">

    <h2>UNIX Web Based Terminal 1.0</h2>
        <br />
    <p><b>output</b></p>
<form>
<span id="User"></span>< <input type="text" id="txtcmd" onkeyup="shell_execute(this.value)" class="textbox" size="20" />
</form>
<div class="output">
<p><span id="txtOut"></span></p>

    </div>
</div>
</body>
</html>

exec.php

<?php

$q=$_GET["q"]; 
$output=shell_exec($q);
echo "<pre>$output</pre>";
?>
like image 527
user478636 Avatar asked Feb 20 '26 22:02

user478636


2 Answers

You need to get the value from your text input element and put that into str before you pass it to your script.

Like:

 var str = $("#txtcmd").val();
like image 157
kafuchau Avatar answered Feb 22 '26 12:02

kafuchau


Instead of

<script type="text/javascript" src="jquery-1.5.2.js"/>

Close your script tag like this:

<script type="text/javascript" src="jquery-1.5.2.js"></script>
like image 34
James Wiseman Avatar answered Feb 22 '26 11:02

James Wiseman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!