後我有主index.php文件和索引我要去到另一個文件categories.php傳球達陣使用jquery點擊格在HTML
這裏的網址是categories.php一個div
<div id="allRings" class="categories">
<img style="margin-top: 10px;" src="images/allrings~iPad.png" alt="" width="100" height="68" /><br /><br />
<label class="catText" >All Rings</label>
</div>
jQuery中我這樣做
jQuery('#allRings').click(function()
{
$.ajax({
type: "POST",
url: "getrings.php?ringType=all", // what ever exact url is
data: "",
success: function(result)
{
//alert(result);
// CALL index.php here with result data
}
});
});
在getRings.php我有功能
if(!empty($_REQUEST['ringType']))
{
$db = new db();
$ringType = $_REQUEST['ringType'];
if ($ringType == "all")
$rings = $db->query("SELECT * FROM rings");
else
$rings = $db->query("SELECT * FROM rings WHERE ringSetCategories LIKE '".$ringType."'");
$response = array();
$response['error'] = '';
$response['status'] = '10';
$response['data'] = $rings;
//echo json_encode($response);
header('location: http://www.xxx.com');
exit;
}
現在我面對的問題是,jquery代碼運行,但是我不知道是否getRings代碼被調用或不,因爲我沒有朝任何網址,當我點擊div.Also如果我必須通過$響應到$ URL我會怎麼做
什麼可能是錯的>?
是_categories.php_在_getrings.php_的子目錄中嗎? –
他們在同一個目錄 –
然後你不需要在'url'中的'../'。它指向它之前的目錄。 –