【发布时间】:2020-01-09 23:48:53
【问题描述】:
我正在尝试调试发布到 action="" 的表单。 一旦提交按钮被按下,它就会被 javascript 验证,然后提交。 我无法弄清楚它在哪里计算便利费。 我需要找到一种方法来跟踪正在发生的事情,以便调试这个空白操作表单。
我已尝试编辑显示数据的刀片模板。 我已经检查了控制器。 我不知道还能去哪里,因为我无法跟踪它在做什么。我拥有的本地开发箱工作正常,但主站点显示的是开发箱没有的默认值。这抵消了页面中的总数,因为它添加了一个应该为 0 的便利费。我已经检查了主服务器和开发箱上的文件,它们是相同的。按下提交按钮后,页面发生变化并变得完全不同。我希望我有足够的细节。
--- abc.blade.php 文件,如果客户有任何大于 0 的值,则显示数据。客户在数据库中设置为 0 ---
@if($cart_details['convenience_param'] != '$')
<p @if($cart_details['convenience_amount']>0) style="display: block;" @else style="display: none;" @endif>Convenience Fee({{$cart_details['convenience_param']}})<span>$<sub id="convAmount">{{ helper::twoDecimalPrice($cart_details['convenience_amount']) }}</sub></span></p>
@else
<p @if($cart_details['convenience_amount']>0) style="display: block;" @else style="display: none;" @endif>Convenience Fee<span>$<sub id="convAmount">{{ helper::twoDecimalPrice($cart_details['convenience_amount']) }}</sub></span> </p>
@endif
--- 您提交订单的页面---
<form autocomplete="on" role="form" id="adminOrder" method="POST" action="" class="row"> ......
</form>
<div class="form-group col-lg-12 submitbtn">
<button onclick="validateForm()" class="btn btn-primary">Submit</button>
</div>
--- 验证所有字段的页面底部的 Java 脚本 ---
function validateForm()
{
var numberRegex = /^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;
var address = $("#address").val();
var date = $("#date").val();
var restaurant_id = $("#restaurant_id").val();
var customer_id = $("#customer_id").val();
var time = $("#time").val();
var zipCode = $("#zip_code").val();
if(restaurant_id.trim().length == ''){
notify('error','Please select restaurant');
}else if(customer_id.trim().length == ''){
notify('error','Please select customer');
}else if(zipCode.trim().length == ''){
notify('error','Please input zip code');
}else if(!numberRegex.test(zipCode)){
notify('error','Please input valid zip code');
}else if(zipCode.trim().length !=5){
notify('error','zipcode must be 5 chracters');
}else if(!jQuery.isNumeric(zipCode)){
notify('error','zipcode must be numeric chracters');
}else if(date.trim().length == ''){
notify('error','Please input date');
}else if(time.trim().length == ''){
notify('error','Please input time');
}else{
$('#adminOrder').submit();
//alert("ok");
}
}
</script>
没有显示类型错误。 该页面根本不应显示任何便利费。 它会显示它们并将其计算到总数中。
【问题讨论】:
-
如果操作为空,它会提交到您用来显示它的当前 URL,但使用 POST 方法,请使用
php artisan route:list检查您的路线