微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在提交按钮单击 php 时提示甜言蜜语

如何解决如何在提交按钮单击 php 时提示甜言蜜语

enter image description here我正在研究 PHP laravel 框架。我需要在单击提交按钮时提示显示条款和条件的甜蜜警报。我不知道使用甜蜜警报。我只是使用了一些模板并编写了以下代码。它不起作用。谁能帮我这个

@extends('layouts.app')
@section('maincontent')
<div class="login-form">
    <div class="container">
        <div class="row ">
            <div class="innerpage-Box">
                @include('layouts.errors')
                <div class="innerpage-Box-header text-center">
                    <h3></b>Products to Buy</h3>
                </div>
                <div class="register-Box-body">
                    <!-- <p class="login-Box-msg">REGISTRATION FORM</p> -->
                    <form role="form" id="myForm" action="/chemOrderSave" method="Post" class="bidDetailSave">
                        @csrf
                        <input type="hidden" name="product_id" value="{{$pro[0]->id}}">
                        <div class="row">
                    
                            <div class="col-md-6">
                                <label> <b> Price: </b>
                                    {{$pro[0]->price * 1.02}}
                                </label> </br>
                                
                                <div class="form-group">
                                    <label for="buyer_quantity"><b> Quantity </b> <star>*</star></label>
                                    <input type="text" class="form-control" id="buyer_quantity" name="buyer_quantity" placeholder="Enter the Quantity" value="{{$pro[0]->quantity}}">
                                </div>


                                <div class="form-group">
                                    <label for="chem_shipping">Shipping</label>
                                    <select name="chem_shipping" class="form-control" required>
                                        <option value="">Please select one of the following Shipping Addresses</option>
                                        @foreach($us as $uss)
                                        <option value="{{$uss->id}}" > {{$uss->address}} {{$uss->city}} {{$uss->state}} {{$uss->zipcode}} {{$uss->country}} </option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                                <button type="submit" class="btn btn-success updateOrder" ><i class="fa fa-save"></i> Submit</button>
                                <a href="/chemClearDashboard/Buyer/{{$pro[0]->user_id}}" class="btn btn-danger" style="font-size: 1rem !important;"><i class="fa fa-close"></i> Cancel</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

在custom.js中我写了以下代码

 $('.container').on('click','.updateOrder',function() {
        //e.preventDefault();
        var id = $(this).attr('id');
        var title = "Are you sure,By Clicking accept you agree to Farmerce's user agreement and are agreeing to follow through on this transaction !";
        swal({
            title: title,type:'warning',showConfirmButton: true,showCancelButton: true,allowOutsideClick: false,confirmButtonText:'Confirm',}).then((result) => {
            if (result.value) {
                $.ajax({
                    type: 'post',url: '/chemBuyer',data: {'_token': $('input[name=_token]').val(),'id':id},success: function(data) { 
                        if(data == 'success'){
                            var title= 'Successfully Order Placed!!!';
                            var type='success';
                        }else{
                            var title= 'Some thing went wrong with the '+name+' !!!';
                            var type='error';
                        }
                        swal({
                            title: title,type:type,confirmButtonText:'OK',}).then(function(){
                            window.location.reload();
                        });
                    }
                });
            }
        })
    });

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。