JqueryForm result in a div



我正在使用jQuery Form插件API提交表单。它是在后台提交的,但我如何在div(id posthere)中显示这个结果(actionpage.php),如下所示。

<form id="myForm" action="actionpage.php" method="post"> 
    Name: <input type="text" name="name" /> 
     <input type="submit" value="Submit Comment" /> 
</form>
<script>
$('#myForm').ajaxForm();
</script>
<div id="posthere" ></div>

请尝试以下代码。

$("#myForm").ajaxForm({
    success: function(res, status, xhr, form) {
        // This will show the direct res over here, you can format it as per your need.
        $('#posthere').html(res);
    }
});

最新更新