【发布时间】:2018-08-29 00:05:54
【问题描述】:
仍然有很多相同的文章,但没有一篇对我有用。 这是PHP代码。
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['preview-form-comment'])){
echo $_POST['preview-form-comment'];
$_SESSION['currentcode']=$_POST['preview-form-comment'];
}
?>
这是表单的html代码。
<form id="preview-form" method="POST">
<textarea required class="codemirror-textarea" rows="100" name="preview-form-comment" id="preview-form-comment"><?php echo $comment ?></textarea>
<br>
<button type="button" id="preview-form-submit">Submit</button>
<!-- <input type="submit" onclick="savedata();" id="preview-form-submit" value="Submit"> -->
</form>
这是脚本。
<script>
$('#preview-form-submit').on('click',function(){
savedata();
$('#preview-form').submit();
});
</script>
【问题讨论】:
-
您的表单缺少 action 属性