Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 2.68 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Jquery AJAX custom form not returning results from PHP
  2. <div id="parentContainer" style="width:100%;">
  3.  
  4.     <div class="container">
  5.         <div class="select" id="cuisineSelect">
  6.         Cuisine
  7.         </div>
  8.         <div class="option" id="cuisineOption">
  9.         <ul id="cuisineul">
  10.             <li>Asian</li>
  11.             <li>American</li>
  12.             <li>Indian</li>
  13.             <li>Fusion</li>
  14.         </ul>
  15.         </div>
  16.     </div>
  17.  
  18.     <div class="container">
  19.         <div class="select" id="locationSelect">
  20.         Location
  21.         </div>
  22.         <div class="option" id="locationOption">
  23.         <ul id="locationul">
  24.             <li>Asian</li>
  25.             <li>American</li>
  26.             <li>Indian</li>
  27.             <li>Fusion</li>
  28.         </ul>
  29.         </div>
  30.     </div>
  31.  
  32.     <div class="container">
  33.         <div class="select" id="priceSelect">
  34.         Price
  35.         </div>
  36.         <div class="option" id="priceOption">
  37.         <ul id="priceul">
  38.             <li>Price Range</li>
  39.             <li>Cheap ($5-$15)</li>
  40.             <li>Medium ($16 - $20)</li>
  41.             <li>Pricey ($21 - $35)</li>
  42.             <li>Fine Dining ($35+)</li>
  43.         </ul>
  44.         </div>
  45.     </div>
  46.  
  47.     <div class="container">
  48.         <div class="select" id="searchButton" style="width:25px; height:20px;">
  49.         <center><img align="center" src="images/sml_search.png" width="17" height="18" /></center>
  50.         </div>
  51.     </div>
  52.  
  53. </div>
  54.  
  55. <div id="result" style="z-index:10;">
  56. result=show;
  57. <?php include "ajax.php"; ?>
  58. </div>
  59.        
  60. $("#searchButton").click(function() {
  61.         /*var cuisine     = $("#cuisineSelect").html();
  62.         var location  = $("#locationSelect").attr('value');
  63.         var price     = $("#priceSelect").attr('value');
  64.             $.ajax({  
  65.                 type: "POST",  
  66.                 url: "ajax.php",  
  67.                 data: "cuisine="+ cuisine +"& location="+ location +"& price="+ price,  
  68.                 success: function(){  
  69.                     $('#result').show();  
  70.                 }  
  71.             });  
  72.         return false;  */
  73.  
  74.         $.post('ajax.php', 'cuisine=' + $("#cuisineSelect").text(), function () {
  75.           $("#result").show();
  76.        });
  77.  
  78.      });
  79.        
  80. <?php
  81.  
  82.     //Search information
  83.     //$cuisine = htmlspecialchars(trim($_GET['cuisine']));
  84.  
  85.     //$location = htmlspecialchars(trim($_POST['location']));
  86.     //$price = htmlspecialchars(trim($_POST['price']));
  87.  
  88.     //echo $location;
  89.     //echo $price;
  90.     //$addClient  = "INSERT INTO clients (fname,lname) VALUES ('$fname','$lname')";
  91.     //mysql_query($addClient) or die(mysql_error());
  92.  
  93.     //$value = $_POST['cuisine'];
  94.     //$value2 = $_POST['val'];
  95.     //echo "$value2";
  96.  
  97.  
  98.     $cuisine = $_POST['cuisine'];
  99.     echo $cuisine;
  100.  
  101. ?>