To do this, you do not have to submit the form, but register the form data using the click event, send the data via AJAX, and as a last ... enter the data into the element DIV. For instance.
JQuery
$("#submitdata").click(function() {
var FormVal={ datafield1:$('#field1').val(),
datafield2:$('#field2').val()};
$.ajax({
type: "POST",
url: "myupdatepage.cfm",
dataType: "json",
data: FormVal,
async: false,
success: function(response) {
$('#fillmein').html($('#field1').val()+'<br />'+$('#field1').val());
}
});
});
HTML
<form action="">
<input type="text" id="field1">
<input type="text" id="field2">
<input type="button" id="submitdata" value="Submit data" />
</form>
<div id="fillmein"></div>
source
share