我想为我的房地产网站创建搜索功能。我已创建搜索条件并满足此条件我使用了jax调用。这个ajax将调用php文件,该文件将数据发送到搜索页面。这是我的示例代码。我不知道那里有什么问题。 谢谢你
function searchBuy() {
//alert("search Loaed");
$.ajax({
url: 'searchBuyCriteria.php',
type: 'POST',
//dataType: "json",
data: {
cat: $('#SelectCat').val(),
MaxArea:$('#SelectMaxArea').val()
}
}).success(function(data){
console.log("Success"+data);
alert(JSON.stringify(data));
}).error(function(data){
console.log("Error"+data);
});
} </scipt>
searchCriteria.php
<?php
include_once('_secure/conn.php');
$city = $_POST['SelectCity'];
$cat= $_POST['SelectCat'];
$rooms = $_POST['SelectRooms'];
$minRange = $_POST['SelectMinRange'];
$maxRange = $_POST['SelectMaxRange'];
$minArea = $_POST['SelectMinArea'];
$maxArea = $_POST['SelectMaxArea'];
$conn=mysql_connect(DB_HOST,DB_USER,DB_PWD,DB_NAME);
mysql_select_db(DB_NAME);
$Searchqry ="Select * from tblcategory where category_title like '%".$cat."%' ";
$searchExec = mysql_query($Searchqry) or die(mysql_error());
$searchRow = mysql_fetch_array($searchExec);
//echo $searchRow;
echo json_encode($searchRow);
?>
conn.php
<?php
session_start();
ob_start();
if(!isset($path))
$path="./";
elseif($path=="")
$path="../";
require_once("settings.inc.php");
$database='srijanip';
$user='srijanip';
$pass='********';
$host='example.*****.in';
define("DB_HOST", "$host");
define("DB_NAME", "$database");
define("DB_USER", "$user");
define("DB_PWD", "$pass");
?>