The following code allows you to process code from a separate PHP page, then dynamically insert the result into the current page using jQuery.  The example below uses a very basic form, extracts the form fields and passes them to a PHP page.  The PHP page could do any calculations or manipulations then output the result.  The result is captured and inserted into the existing page without ever having to reload the page.  Note: This is not a secure setup.  You'd want to make sure you PHP page only outputs secure code to avoid XSS attacks.  Review this link for more information.

page1.php
{codecitation class="brush:html"}

<script type='text/javascript' src='http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js'></script>

<script type="text/javascript">
     $(document).ready(function(){
       $("#opener").click(function(event){
           $.ajax({
               url: "page2.php?s=" + parseInt($("#start").val()) +
                       "&c=" + $("#color").val() +
                       "&n=" + $("#name").val() +
                       "&dn=" + parseFloat($("#dn").val()),
               cache: false,
               success: function(html){
                 $("#result").html(html);
               }
             });
       });
     });
</script>

<form >
<select id="start" name ="start">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
</select>
  
<select id="color" name="color">
    <option value="red">red</option>
    <option value="blue">blue</option>
    <option value="green">green</option>
</select>
<br /><br />
Name: <input type="text" name="name" id="name"  />
<br /><br />
Some Decimal Number <input type="text" name="dn" id="dn"  />
<br /><br />
<button id="opener" onclick="return false">Do It</button>
</form>


<div id="result">
    <p></p>
</div>{/codecitation}

 

page2.php
{codecitation class="brush:php"}

<?php

echo $_GET['s'] . '<br />';
echo $_GET['c'] . '<br />';
echo $_GET['n'] . '<br />';
echo $_GET['dn'] . '<br />';

?>

{/codecitation}