我有一個jQuery過濾顏色查詢中顯示的一些項目。PHP的jQuery傳遞多個單詞的值
問題出現諸如「藍色海軍」之類的顏色。顯然,jQuery不會傳遞這兩個單詞或其他東西。當我回顯_GET
值的結果時,如果傳遞了2個單詞的顏色,我從來沒有收到任何內容,而我確實獲得了單字顏色的值。
任何想法爲什麼發生這種情況?
這裏是我的代碼:
jQuery(document).ready(function($) {
$("input:checkbox").change(function() {
if($(this).is(':checked'))
{
$(".loadingItems").fadeIn(300); //fade in on change
var color = $(this).val();
$(".indexMain").load('indexMain.php?color='+color,function(){
$(".indexMain").fadeIn(slow);
})
$(".loadingItems").fadeOut(300); //remove when load is complete
}
else
{
$(".loadingItems").fadeIn(300); //fade in on change
$(".indexMain").load('indexMain.php');
$(".loadingItems").fadeOut(300); //remove when load is complete
}
});
});
$color = $_GET['color'];
$items = $con -> prepare("SELECT * FROM item_descr WHERE color_base1 = :colorbase1");
$items -> bindValue(":colorbase1", $color);
解釋嘗試'變種顏色= $(本).VAL()。的toString()。REPLACE(」 ',' - ');' – PitaJ 2012-08-12 16:43:49
@PitaJ,它不應該是'+'而不是'-'嗎?另外,'.val()'返回一個字符串。 – Adi 2012-08-12 16:45:44