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 对法兰连接元件所承受的表面载荷等效转化为法兰开孔接触面上的等效表面载荷?
  • ¥15 comsol仿真压阻传感器
  • ¥15 Python线性规划函数optimize.linprog求解为整数
  • ¥15 llama3中文版微调
  • ¥15 在win系统Django虚拟环境下载mysqlclient报错
  • ¥15 pg数据库导入数据序列重复
  • ¥15 三分类机器学习模型可视化分析
  • ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)
  • ¥50 Qt在release捕获异常并跟踪堆栈(有Demo,跑一下环境再回答)
  • ¥30 python,LLM 文本提炼