I am trying to pass a variable from my javascript code to the server side PHP code. I know this must be done via an ajax, But unfortunately I do not receive the value in the PHP variable in blade view.
form : url = facture=20
{!! Form::open(array('url'=> 'admin/facture=20', 'method'=>'post', 'name'=>'pushds')) !!}
{!! Form::hidden('ms_id', $fact->id) !!}
{!! Form::hidden('mstid', $fact->b_id, array('id' => 'mstid')) !!}
{!! Form::close() !!}
jquery :
$('form[name="pushds"]').on('submit', function (e){
e.preventDefault();
var mstid = $('#mstid').val();
var ms_id = $('#ms_id').val();
$.ajax({
type: 'post',
url: 'facture=20',
data: {mstid: $('#mstid').val(), ms_id : $('#ms_id').val()},
success: function( data ) {
......
},
the current page url : facture=20
the variable php in blade view
<?php
if (!empty($_POST["mstid "])) {
echo $_POST['mstid '];
}
?>