0

I am using the jQuery Form plugin API to submit a form. It is submitting in the background, but how do I show this result (actionpage.php) in a div (with id posthere) as shown below.

<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>
jfet93
  • 21
  • 3
  • You have to put a callback function to `ajaxForm` to handle the result. Please check http://stackoverflow.com/questions/14754619/jquery-ajax-success-callback-function-definition – mario.van.zadel Jul 28 '16 at 05:47

1 Answers1

0

Please try following code.

$("#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);
    }
});
Mohit Tanwani
  • 6,608
  • 2
  • 14
  • 32