【发布时间】:2016-05-11 11:54:18
【问题描述】:
我有一个 textarea 和这个 javascript 代码它应该可以工作,但是有什么问题吗?如果是这样,它是什么?
$('#text').load("http://hokuco.com/test/xe7/user.txt");
<form action="formcode.php" method="POST">
<textarea name='field2' placeholder='Code here' rows ="40" cols="40" id ="text"></textarea>
<br />
<input type="submit" name="submit" value="Save">
</form>
如果好奇,这是我的 php 文件:
<?php
if(isset($_POST['field1']) && isset($_POST['field2'])) {
$data = $_POST['field1'] . '-' . $_POST['field2'] . "\n";
$ret = file_put_contents('code.txt', $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
echo "$ret bytes written to file";
}
}
else {
die('no post data to process');
}
?>
【问题讨论】:
-
您是否将其绑定到某个事件,或包裹在
$(document).ready(function(){});语句中? -
不,我想这就是我所有的代码............
-
我希望当html6出来的时候他们会在textarea标签中添加一个href控件