1
這是我的javascript代碼。在這裏我宣佈了一個名爲total_price
的變量。我想用ajax將這個變量值傳遞給php變量。這個怎麼做?如果有人能幫助我做到這一點,我將不勝感激。謝謝。任何人都可以使用此代碼來做到這一點。如何使用ajax將jQuery變量值傳遞給php變量?
$(document).ready(function() {
$('#roomOptions #select1, #select2, #select3').change(function() {
var total = 0;
var total1=0;
var Adult_price =0;
var total2=0;
var children_price=0;
var total_price=0;
$('#roomOptions #select1').each(function() {
total+=parseInt($(this).val());
});
$('#roomOptions #select2').each(function() {
total1+=parseInt($(this).val());
});
$('#roomOptions #select3').each(function() {
total2+=parseInt($(this).val());
});
Adult_price = total * total2;
children_price = (total1 * total2)/2;
total_price = (Adult_price + children_price + room_rate) * no_of_nights ;
$('#roomOptions #roomOptions_total3').html(Adult_price);
$('#roomOptions #roomOptions_total4').html(children_price);
$('#roomOptions #roomOptions_total').html(total);
$('#roomOptions #roomOptions_total5').html(total_price);
$('#roomOptions #roomOptions_total1').html(total1);
$('#roomOptions #roomOptions_total2').html(total2);
$('#roomOptions #roomOptions_total6').html(room_rate);
});
});
哪裏是你的Ajax請求?如果你問如何做ajax請求,請參閱[jquery docs](http://api.jquery.com/jQuery.ajax)for ajax –
是的。我需要如何提出ajax請求。請幫幫我 –