2017-09-18 13:58
浏览 54


I created a form with javascript validation. if the validation is complete i will redirect to another page with javascript. but I need invoice variable from a controller that I need to send to the page I point to later.

my javascript:

    url  : baseURL +"checkout/endVerify_order",
    type : "GET",
    data : {starssecure: csrf, gex: g, almt: addr, prov: na_prop, city: na_cit, w: wei, exp: ex, resex: exresul, pay: mePay, bnk: bnkifyes, grt: gTotat},
    beforeSend: function(){
    success: function (sndOrder){
        if(sndOrder == "Lnswg&g2390"){
            $(".bnk_in").html("Choose Bank!");
            $(".pushp").html("Lengkapi Form diatas!");
        }else if(sndOrder == "validate_complete"){
            window.location.href = baseURL + 'finishorder';

and my controller :

function endVerify_order(){
echo "validate_complete";
$invoice = "AB18253";
$datap = $invoice;
echo json_encode($datap);

and my view for finishorder :

div class="col-lg-12 col-xs-12">
        <div id="shf" class="row">
            <div class="col-lg-12 col-xs-12">
            <div class=" text-center">
                <i class="glyphicon glyphicon-ok bort"></i><br>
                <h4>Your Order is Successfully</h4>
                <b>No. Invoice #<span id="inv"></span></b>
                <p class="text-justify">Thankyou for Order.</p>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • drhzn3911 2017-09-18 14:05

    In Controller, jsonize the values as following,

    function endVerify_order(){
    $data['status'] =  "validate_complete";
    $data['invoice'] = "AB18253";
    $data['datap'] = $invoice;
    echo json_encode($data);exit;

    Now you can directly check if(sndOrder.invoice == "Lnswg&g2390"){ }

        window.location.href = baseURL + 'finishorder/'+sndOrder.invoice;

    You can access in controller function,

    function finishorder($invoiceid)
        //$invoiceid which is sent from javascript
    解决 无用
    打赏 举报

相关推荐 更多相似问题