weixin_33670713 2015-07-01 03:03 采纳率: 0%
浏览 24

如何调试Ajax脚本

I try to find why something doesn't in my script

My problem is in discount_code. I try to see if there is something or not and if the data is ok, but I don' see nothing.

How to see for example $sess_discount_code or all data that I want in discount_code.php to try to debug the file ?

Thank you

In my shopping_cart.php, I have that

if (MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true') {
  global $sess_discount_code;
  $footer .= '
  $(document).ready(function() {
    var a = 0;
    discount_code_process();
    $(\'#inputCoupon\').blur(function() { if (a == 0) discount_code_process(); a = 0 });
    $("#inputCoupon").keypress(function(event) { if (event.which == 13) { event.preventDefault(); a = 1; discount_code_process() } });
    function discount_code_process() { if ($("#inputCoupon").val() != "") { $("#inputCoupon").attr("readonly", "readonly"); $("#discount_code_status").empty().append(\'<i class="fa fa-cog fa-spin fa-lg">&nbsp;</i>\'); $.post("discount_code.php", { inputCoupon: $("#inputCoupon").val() }, function(data) { data == 1 ? $("#discount_code_status").empty().append(\'<i class="fa fa-check fa-lg" style="color:#00b100;"></i>\') : $("#discount_code_status").empty().append(\'<i class="fa fa-ban fa-lg" style="color:#ff2800;"></i>\'); $("#inputCoupon").removeAttr("readonly") }); } } });
  ';
}

$footer .= '
</script>
<!-- End shipping estimator -->
';



// Discount Code - start
          if (MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true') {
            if ($sess_discount_code == 'undefined') $sess_discount_code = '';


            $discounttxt = '<div class="col-sm-12 row">';

            if ($OSCOM_Customer->isLoggedOn()) {

              $discounttxt .= '<div class="col-sm-12"><strong>' . MODULE_SHOPPING_CART_SHIPPING_ESTIMATOR_DISCOUNT_CODE_TITLE . '</strong></div>
                               <div class="col-sm-5">' . HTML::inputField('coupon', $sess_discount_code, 'id="inputCoupon"') . '<span id="discount_code_status"></span></div>

                               <div class="col-sm-6"><a class="btn btn-default" role="button" href="_" onclick="return shipincart_submit(\'\');"><i class="glyphicon glyphicon-refresh"></i>&nbsp;'. IMAGE_BUTTON_UPDATE . ' </a></div>';
            } else {

              $discounttxt .= '<div class="col-sm-12">' . MODULE_SHOPPING_CART_SHIPPING_ESTIMATOR_DISCOUNT_CODE_TEXT_LOG_IN . '</div>
                               <div class="col-sm-12">' . HTML::button(MODULE_SHOPPING_CART_SHIPPING_ESTIMATOR_BUTTON_LOGIN, 'glyphicon glyphicon-log-in', OSCOM::link('login.php'), 'btn-success btn-sm') . '</div>';
            }

            $discounttxt .= '</div>
                          <div class="hr"></div>
                          <div class="clearfix"></div>
                          <div class="hr"></div>
                          ';
            $ShipTxt .= $discounttxt;
          }
// Discount Code - end

In my discount_code.php, I have that :

  $discount = 0;

  var_dump($sess_discount_code); ===> How to see that ????

  if (MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true' && !empty($_SERVERS['HTTP_X_REQUESTED_WITH']) && $SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {

    ................


 }

  register_shutdown_function('session_write_close');

  echo $discount > 0 ? 1 : 0;

  exit;
  • 写回答

1条回答 默认 最新

  • 乱世@小熊 2015-07-01 05:26
    关注

    There exists chuncks of tools to do such tasks, such as Finddler or Charles. You can use them to watch HTTP requests and response including ajax.

    评论

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行