我需要關於jQuery和ajax的幫助。提交後需要從文件中加載textarea內容。 無法弄清楚這一點。下面的代碼:jquery表單提交和textarea刷新
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />
<style type="text/css">
/*<![CDATA[*/
#output {
resize: none;
width:100%;
height:70%;
}
#time {
background-color:#0F0;
}
#command {
width:80%;
}
#submit {
width:18%;
}
/*]]>*/
</style>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
var psconsole = $('#output');
psconsole.scrollTop(
psconsole[0].scrollHeight - psconsole.height());
});
$(document).ready(function() {
$("#execute").validate({
debug: false,
rules: {
name: "required",
email: {
required: true,
email: true
}
},
messages: {
name: "Please let us know who you are.",
email: "A valid email will help us get in touch with you.",
},
submitHandler: function (form) {
// do other stuff for a valid form
$.post('ajax.php', $("#execute").serialize(), function (data) {
$('#output').html(data);
});
}
});
});
//]]>
</script>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<title></title>
</head>
<body>
<textarea readonly="readonly" cols="150" id="output">
<?php
echo $api->consoleOutput(50, 0); ?>
</textarea>
<form action="" name="execute" method="post" id="console">
<input type="text" id="command" name="command" /> <input type="submit" id="submit"
value="siųsti" /> <button id="button">siusti</button>
</form><?php
$api->sendCommand($_POST['command'])
?>
</body>
</html>
我已經試過了,似乎並沒有幫助快速解答... 規則#1中的所有其他方法;)
你還需要包含插件,通常它被命名爲'jquery.validate.js' – 2011-12-20 13:55:43
這實際上有效,謝謝:) – 2011-12-20 14:13:41
乾杯,編輯我的答案以及然後。 – 2011-12-20 14:24:44