【发布时间】:2014-01-24 20:33:18
【问题描述】:
我有两个复选框,其中一些值如下:
<label for="hotel_boutique"><input id="hotel_boutique" name="hotel_boutique" value="test" type=checkbox />test</label><br />
3
我通过这样的 Ajax 调用获得这些值:
<script>
jQuery("input[type='checkbox']").change(function(){
if (jQuery('input#hotel_boutique').is(':checked')) {
var hotel_boutique = jQuery("#hotel_boutique").map(function () {return this.value;}).get();
}else{
var hotel_boutique = 'NULL';
}
if (jQuery('input#hotel_stars').is(':checked')) {
var hotel_stars = jQuery("#hotel_stars").map(function () {return this.value;}).get();
}else{
var hotel_stars = 'NULL';
}
var data = 'hotel_boutique="'+hotel_boutique+'"&hotel_stars="'+hotel_stars+'"';
jQuery.ajax({
url: "processAjax.php",
type: "GET",
data: data,
cache: false,
beforeSend: function() {
jQuery("#loading").show();
},
success: function(data, textStatus, XMLHttpRequest){
jQuery("#content").html('');
jQuery("#content").append(data);
jQuery("#loading").hide();
},
error: function(MLHttpRequest, textStatus, errorThrown){
alert(errorThrown);
}
});
});
</script>
现在,当我在服务器端 (PHP) 中回显变量时,它会显示:
"test"
" 添加了谁以及为什么添加?我怎样才能删除它们?
我已经尝试过PHP函数preg_replace和其他东西。
请需要你的帮助...
【问题讨论】:
标签: php jquery ajax variables parameter-passing