title: Jquery .load() with data from form
body: <p>I am trying to load a page into a modal window "checkout.php" after submitting a form, but I need it to load with the results of the form. Normally, one would just set the action of the form to the url and the data gets passed, but in this case, the page needs to be loaded into a modal with that data which requires the use of more jQuery than I know.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form id="shippingform" name="shippingform" method="post" action="#"&gt;
  &lt;table id="box-table-a" width="25%" border="1"&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th scope="col" width="40%"&gt;USPS Option&lt;/th&gt;
          &lt;th scope="col" width="40%"&gt;Price&lt;/th&gt;
          &lt;th scope="col" width="20%" style="text-align: right;"&gt;Select&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
    &lt;td class="first"&gt;Ground:&lt;/td&gt;
    &lt;td&gt;&lt;?php echo "$" . sprintf("%01.2f", $groundTotal) ?&gt;&lt;/td&gt;
    &lt;td class="last"&gt;&lt;input name="shipping" type="radio" id="radio" value="&lt;?php echo $groundTotal ?&gt;" checked="checked" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class="first"&gt;Priority:&lt;/td&gt;
    &lt;td&gt;&lt;?php echo "$" . sprintf("%01.2f", $priorityTotal) ?&gt;&lt;/td&gt;
    &lt;td class="last"&gt;&lt;input type="radio" name="shipping" id="radio2" value="&lt;?php echo $priorityTotal ?&gt;" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class="first"&gt;Express:&lt;/td&gt;
    &lt;td&gt;&lt;?php echo "$" . sprintf("%01.2f", $expressTotal) ?&gt;&lt;/td&gt;
    &lt;td class="last"&gt;&lt;input type="radio" name="shipping" id="radio3" value="&lt;?php echo $expressTotal ?&gt;" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;a href="#" onclick="totalCalc()"&gt;submit&lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  function totalCalc() {
  $('#cartdialog').load("/ash/shop/checkout.php");
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>What I have above will load the checkout.php page into the modal after clicking the submit button for the form. I AM NOT asking why the page isnt loading with the information sent with the form. I completely understand that what I am doing here is simply executing a function to load "checkout.php" into the div that is the modal. I need someone to explain to me how I can edit my function so that "checkout.php" gets loaded like if it were the action of the form, the data would be passed through.</p>
  
  <p>Thanks in advance for the help!</p>
  
  <p>EDIT BELOW</p>
  
  <pre><code>&lt;form id="shippingform" name="shippingform" method="post" action="#"&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>$('#shippingform').submit(function(event){
  var data = $(this).serialize();
  $.post('/ash/shop/checkout.php', data)
      .success(function(result){
          $('#cartdialog').html(result);
      })
      .error(function(){
          console.log('Error loading page');
      })
  return false;
  });
  </code></pre>
  
  <p>THE CHECKOUT.PHP PAGE WHERE IT CALLS THE INPUT "shipping"</p>
  
  <pre><code>&lt;?php 
  //total up price of all items
  $subtotal = ($subtotal + ($row_rsMyCart['price'] * $row_rsMyCart['quantity']));
  $myTotal = ($subtotal + $_POST['shipping']);
  
  } while ($row_rsMyCart = mysql_fetch_assoc($rsMyCart)); ?&gt;
  &lt;/table&gt;
  &lt;p&gt;
  &lt;?php
  //development
  echo "&lt;br&gt;";
  echo "Subtotal: $" . sprintf("%01.2f", $subtotal);
  echo "&lt;br&gt;";
  echo "Total: $" . sprintf("%01.2f", $myTotal);
  ?&gt;
  &lt;/p&gt;
  </code></pre>