我没有收到此代码的任何输出。什么可能是错误。jQuery .keyup()函数
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>";
?>
你的网址没有'不符合你列出的文件的名字......错字?另外,我们可以看到其余的HTML吗?输入元素在哪里绑定? – kafuchau 2011-04-12 12:10:51
在你的标题中你提到了.keyUp()函数。是不是被触发的函数,或者是没有响应的ajax调用。 – 2011-04-12 12:11:11
哪里设置了“str”? – 2011-04-12 12:11:50