Form from Ajax loaded page

Form from Ajax loaded page

so I have a page that loads content via AJAX.
  1. $('#responseForm<?php echo $id; ?>').submit(function(){$('input[type=submit]', this);});

  2. function parseResponse<?php echo $id; ?> () 
  3. {
  4. var hiddenField2<?php echo $id; ?> = $("#hiddenField2<?php echo $id; ?>");
  5. var hiddenField<?php echo $id; ?> = $("#hiddenField<?php echo $id; ?>");
  6. var hiddenField1<?php echo $id; ?> = $("#hiddenField1<?php echo $id; ?>");

  7. var url = "news_parse1.php";
  8. $.post(url,{  hiddenField2: hiddenField2<?php echo $id; ?>.val(),hiddenField: hiddenField<?php echo $id; ?>.val(), hiddenField1:hiddenField1<?php echo $id; ?>.val()  } , 
  9. function(data) {
  10. });
  11. setTimeout(function() {

  12. $.ajax({
  13. type:"POST",
  14. url:"news_load1.php",
  15. data:"getNews=true",
  16. success: function(r){
  17. $("#newsContent").html(r),
  18. $("#newsContent").append(r);

  19. },
  20. error: function(){
  21. alert($(".hiddenField2<?php echo $id; ?>").val());
  22. $("#error").text($(".hiddenField2<?php echo $id; ?>")).fadeIn(300)
  23. }
  24. })


  25. },200);
  26. }
then this page is the loaded page:
  1. <?php 
  2. session_start();
  3. include_once("connect.php");

  4.    



  5. $cid = 'abcdefghijklmnop';  
  6.  $academy = 'Old_Cheney';
  7.  if($academy=="Old_Cheney"){$city= "Lincoln";}else if($academy=="Yankee_Hill"){$city= "Lincoln";}else if($academy=="Holdrege"){$city= "Lincoln";}else if($academy=="Maple"){$city= "Omaha";}
  8.  else if($academy=="Center"){$city= "Omaha";}
  9.  else if($academy=="Pensacola"){$city= "Pensacola";}
  10. $sql = mysql_query("SELECT * FROM login where academy ='$academy'");
  11. ?>
  12.  <?php
  13. if(($_POST['submit'])){
  14. $price=$_POST["price"];
  15. $quant=$_POST["qty"];
  16. $id=$_POST["id"];

  17. $discount=$_POST["discount"];

  18. $point=".";
  19. $disc= $point.$discount;
  20. if(isset($_POST['discount'])){$price1=$price * $disc;
  21. $price2= $price - $price1;

  22. mysql_query("UPDATE cart SET price = '$price2', quantity = '$quant' WHERE id = '$id' ");
  23. }else{
  24. mysql_query("UPDATE cart SET price = '$price', quantity = '$quant' WHERE id = '$id' ");
  25. }
  26. ?>
  27. <script>
  28. $("#newsContent").load("index.php #newsContent");

  29. </script>
  30. <?php
  31. }

  32. ?> 
  33. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  34. <html xmlns="http://www.w3.org/1999/xhtml">
  35. <head>
  36. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  37. <title>Untitled Document</title>
  38. <script src="scripts/jquery-1.6.1.min.js" type="text/javascript"></script>
  39. <script src="scripts/jquery.dataTables.min.js" type="text/javascript"></script>
  40. <script src="scripts/jquery.dataTables.columnFilter.js" type="text/javascript"></script>
  41. <script src="scripts/jquery.dataTables.pagination.js" type="text/javascript"></script>
  42. <link href="css/data_table.css" rel="stylesheet" type="text/css" />
  43. <style type="text/css">
  44. /* BeginOAWidget_Instance_2586523: #dataTable */

  45. @import url("css/custom/base/jquery.ui.all.css");
  46. #dataTable {padding: 0;margin:0;width:100%; }
  47. #dataTable_wrapper{width:80%;
  48. }
  49. #dataTable_wrapper th {cursor:pointer} 
  50. #dataTable_wrapper tr.odd {color:#000; background-color:#FFF}
  51. #dataTable_wrapper tr.odd:hover {color:#333; background-color:#CCC}
  52. #dataTable_wrapper tr.odd td.sorting_1 {color:#000; background-color:#999}
  53. #dataTable_wrapper tr.odd:hover td.sorting_1 {color:#000; background-color:#666}
  54. #dataTable_wrapper tr.even {color:#FFF; background-color:#666}
  55. #dataTable_wrapper tr.even:hover, tr.even td.highlighted{color:#EEE; background-color:#333}
  56. #dataTable_wrapper tr.even td.sorting_1 {color:#CCC; background-color:#333}
  57. #dataTable_wrapper tr.even:hover td.sorting_1 {color:#FFF; background-color:#000}
  58. /* EndOAWidget_Instance_2586523 */
  59. </style>
  60. <script type="text/xml">
  61. <!--
  62. <oa:widgets>
  63.   <oa:widget wid="2586523" binding="#dataTable" />
  64. </oa:widgets>
  65. -->
  66. </script>
  67. </head>

  68. <body>
  69. <script type="text/javascript">
  70. // BeginOAWidget_Instance_2586523: #dataTable

  71. $(document).ready(function() {
  72. oTable = $('#dataTable').dataTable({
  73. "bJQueryUI": true,
  74. "bScrollCollapse": false,
  75. "sScrollY": "125px",
  76. "bAutoWidth": true,
  77. "bPaginate": true,
  78. "sPaginationType": "two_button", //full_numbers,two_button
  79. "bStateSave": true,
  80. "bInfo": false,
  81. "bFilter": false,
  82. "iDisplayLength": 100,
  83. "bLengthChange": false,
  84. "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]]
  85. });
  86. } );
  87. // EndOAWidget_Instance_2586523
  88. </script>
  89. <table cellpadding="0" cellspacing="0" border="0" id="dataTable">
  90.   <thead>
  91.     <tr>
  92.           <th>ID</th>

  93.       <th>Product</th>
  94.       <th>Category</th>
  95.       <th>Price</th>
  96.       <th>Quantity</th>
  97.       <th>Discount</th>
  98.     </tr>
  99.   </thead>
  100.   <tbody>
  101.     <!--Loop start, you could use a repeat region here-->
  102.     <?php
  103. if(isset($_POST['getNews'])){
  104. $sql1= mysql_query("SELECT * FROM cart where cart_id='$cid' ORDER BY id ASC ");
  105. while($row1 = mysql_fetch_array($sql1)){
  106. $price = $row1['price'];
  107. $product = $row1['product123'];
  108. $id = $row1['id'];
  109. $qty = $row1['quantity'];
  110. $category = $row1['category'];

  111. $total =  $price + $total;
  112. if ($total == " "){$total = "0";} 
  113. ?>
  114.     <form action="news_load1.php" method="post" name="form"><tr height="10">
  115.           <td><input name="id" type="text" value="<?php echo $id; ?>" size="5" /></td>

  116.       <td><?php echo $product; ?></td>
  117.       <td><?php echo $category; ?></td>
  118.       <td><input name="price" type="text" value="<?php echo $price; ?>" size="5" /></td>
  119.       <td><input name="qty" type="text" value="<?php echo $qty; ?>" size="5" /></td>
  120.       <td><input name="discount" type="text" value="" size="5" /> <input name="submit" type="submit" /></td>
  121.       
  122.    </tr></form>
  123.    <?php
  124. }}
  125. ?>
  126.   </tbody>
  127. </table>
  128. <?php echo $total; ?>
  129. </body>
  130. </html>
How do I make it so that the form in the loaded page will submit via ajax or php(like I am trying to now, but it doesn't submit).  any help on this?