I need help with jQuery and ajax. need to load textarea content from file after submit.
can’t figure out this. here’s the code:
<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>
all the other methods I have tried, the doesn’t seem to help…
Stackoverflow rules for fast answers 😉
Your form ID is “console”, not “execute” so change this line:
To this:
You can also select the form by its name, but can’t see any advantage in this.
Edit: in order for all of this to work, you also have to reference the plugin itself, usually named
jquery.validate.js.