0

我有 2 个单独的函数在同一页面上提交(listing_details.tpl.php)。一个不起作用,我想可能是因为其中一个提交是使用 AJAX。我对任何可能的解决方案都很感兴趣。

控制台中的错误读取

POST http://staynsurf.biz/modules/listing/post.php 404 (Not Found) 

book_it_button 的 Javascript

function subTotal() {
    var check_in = $('#checkin').val(); 
    var check_out = $('#checkout').val();
    var guest = $('#number_of_guests').val();

if(check_in!='' && check_out!='' && guest!='') {
    $('.spinner').show();
    $.ajax({
        type: "POST",
        url: '<?php print SITE_MOD; ?>listing/ajax_subtotal.php',
        data: $('#book_it_form').serialize(),
        dataType:'json',
        success: function(data) {
            $('.spinner').hide();
            if(data['result'] == 'success'){
                $('#subtotal').html('<?php echo $_SESSION["ses_currency_symbol"]; ?>'+data['pricing']);
                $('#book_it_button').removeAttr('disabled');
                $('#show_more_subtotal_info').css({'display':'block'});
                $('#service_fee').html('<?php echo $_SESSION["ses_currency_symbol"]; ?>'+data['service_fee']);
                $('#sub_total').val(data['pricing']);
                $('#serviceFee').val(data['service_fee']);
            } else {
                $('#book_it_enabled').css({'display':'none'});
                $('#show_more_subtotal_info').css({'display':'none'});
                $('#book_it_disabled').css({'display':'block'});
                $('#book_it_disabled_message').html(data['error']);
                return false;
            }
        }
    });
    return false;
}
}

$("#checkin, #checkout").attr( 'readOnly' , 'true' );
$("#checkin, #checkout").keypress(function(event) {event.preventDefault();});
$(function() {
var dates = $( "#checkin, #checkout" ).datepicker({
    minDate:0,
    maxDate:"+3Y",
    nextText:"",
    prevText:"",
    numberOfMonths:1,

    changeMonth: false,
    onSelect: function( selectedDate ) {
        var option = this.id == "checkin" ? "minDate" : "maxDate",
        instance = $( this ).data( "datepicker" ),
        date = $.datepicker.parseDate(
        instance.settings.dateFormat ||
        $.datepicker._defaults.dateFormat,
        selectedDate, instance.settings );

        dates.not( this ).datepicker( "option", option, date );
        var i=$.datepicker._defaults.dateFormat;
        j=$.datepicker.parseDate(i,$("#checkin").val());
        l=$.datepicker.parseDate(i,$("#checkout").val());
    },
    onClose: function(){
        $('#book_it_button').attr({'disabled':'disabled'});
        $('#subtotal').html('');
        $('#show_more_subtotal_info').css({'display':'none'});
        $('#book_it_disabled').css({'display':'none'});
        $('#book_it_enabled').css({'display':'block'});
        if(this.id== "checkin") {
            var theDate = new Date($(this).datepicker('getDate'));
            // this sets "theDate" 1 day forward of start date
            theDate.setDate(theDate.getDate() + 1);
            // set min date for the end date as one day after start date
            $('#checkout').datepicker('option','minDate',theDate);
        }
        subTotal();
    }
});
});

book_it_button 的输入

   <button type="submit" class="button-glossy green" id="book_it_button" disabled="disabled">

其他提交的Javascript

       <script type="text/javascript">
  $(function () {
    $('form').on('submit', function (e) {
      $.ajax({
        type: 'post',
        url: 'post.php',
        data: $('form').serialize(),
        success: function () {
          alert('form was submitted');
        }
      });
      e.preventDefault();
    });
  });
</script>
4

1 回答 1

0

将每个提交按钮和相关字段放在它自己的部分中。

于 2013-10-28T15:21:51.987 回答