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:
$.ajax({
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(){
$(".bg-form-che").removeClass("hidden");
},
success: function (sndOrder){
$(".bg-form-che").addClass("hidden");
if(sndOrder == "Lnswg&g2390"){
$(".bnk_in").html("Choose Bank!");
$(".alam_in").html("");
$(".ex_in").html("");
$(".prop_in").html("");
$(".city_in").html("");
$(".resex_in").html("");
$(".pay_in").html("");
$(".pushp").html("Lengkapi Form diatas!");
$(".citKey").removeClass("border-error");
$("#addrKey").removeClass("border-error");
$("#propKey").removeClass("border-error");
$(".tb_result").removeClass("border-error");
}else if(sndOrder == "validate_complete"){
$("#inv").val(sndOrder.datap);
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>
</div>
</div>
</div>
</div>