*Updated with full code example, after reading comments I figured I'd post example code that I'm still struggling with. Basically I'm hoping clicking on the link in the html with submit the form to called.php and return it's value into the div on the html page.
<!DOCTYPE html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function dSubmit(){
$.ajax({
type: "POST",
url: "called.php",
data: $("#projectAddition").serialize(),
success: function(data) {
//here id where you want display
$('#id1').val(data.var1); //here is value1
}
}
}
</script>
</head>
<body>
<form id="projectAddition" action="#" method="POST">
<input type="text" name="projectName">
</form>
<a href="#" onclick="dSubmit()">Submit Form</a>
<br>Output<br>
<div id="id1"></div>
</body>
PHP:
$name = $_POST['projectName'];
// Do something with variable
$array = array(
'var1'=> $name,
'var2'=>'value2'
);
echo json_encode($array);