3

我遇到的问题是在“交付方法”部分中,Ajax 由于某种原因无法验证。

在下面的代码中(来自 checkout/checkout.tpl),BeforeSend 和 complete 函数正在触发,但成功中的函数没有触发。

谁能告诉我 'index.php?route=checkout/shipping_method/validate' 设置在哪里?

谢谢

$('#button-shipping-method').live('click', function() {
   $.ajax({
      url: 'index.php?route=checkout/shipping_method/validate',
      type: 'post',
      data: $('#shipping-method input[type=\'radio\']:checked, #shipping-method textarea'),
      dataType: 'json',
      beforeSend: function() {
         $('#button-shipping-method').attr('disabled', true);
         $('#button-shipping-method').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
      },   
      complete: function() {
         $('#button-shipping-method').attr('disabled', false);
         $('.wait').remove();
      },         
      success: function(json) {
         $('.warning, .error').remove();

         if (json['redirect']) {
            location = json['redirect'];
         } else if (json['error']) {
            if (json['error']['warning']) {
               $('#shipping-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');

               $('.warning').fadeIn('slow');
            }         
         } else {
            $.ajax({
               url: 'index.php?route=checkout/payment_method',
               dataType: 'html',
               success: function(html) {
                  $('#payment-method .checkout-content').html(html);

                  $('#shipping-method .checkout-content').slideUp('slow');

                  $('#payment-method .checkout-content').slideDown('slow');

                  $('#shipping-method .checkout-heading a').remove();
                  $('#payment-method .checkout-heading a').remove();

                  $('#shipping-method .checkout-heading').append('<a>Modify &raquo;</a>');   

               },
               error: function(xhr, ajaxOptions, thrownError) {
                  alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
               }
            });               
         }
      },
      error: function(xhr, ajaxOptions, thrownError) {
         alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
      }
   });   
});
4

2 回答 2

4

由于 url 显示了控制器结构,validate您可以在具有名称的类中找到该函数,该名称ControllerCheckoutShippingMethod位于

目录\控制器\结帐\shipping_method.php

于 2013-08-16T22:48:00.320 回答
0

结帐使用许多页面,因为您的 Ajax URL 是

url: 'index.php?route=checkout/shipping_method/validate',

它使用功能验证从页面 checkout/shipping_method.php 检索数据。

和客人结帐

checkout/guest.php    


public function save() {//this function consist validation

checkout/shipping_method.php
checkout/payment_method.php

您可以在 firebug 中使用控制台进行检查,这将使您清楚当前正在运行的通过 ajax 调用的部分或页面。

于 2016-06-03T11:40:07.567 回答