2 months ago

assign variable in ajax

Posted 2 months ago by Aronaman

controller pass variable to blade and how can pass to ajax variable?


 public function create(Request $request, Room $room)
	$diffDate= $check_out->diffInDays($check_in);
        return view('International', compact('room','diffDate',' resultCount'));


 <label > Select Qty:</label><br>

<div  class="form-check">
     <select  id="qty" name="qty">
	<option value="">--- Select Qty ---</option>
		@for ($i = 1; $i < $resultCount; $i++) 
		<option value="{{$i}}">{{$i}}</option>

<h4 class="d-flex justify-content-between align-items-center mb-3">
        <span class="text-muted">Reservation Info</span>

 <li class="list-group-item d-flex justify-content-between lh-condensed">
	       <h6 class="my-0">No Date</h6>      
	       <span class="text-muted">{{ $diffDate }}</span>

<li class="list-group-item d-flex justify-content-between lh-condensed">
	         <h6 class="my-0">Quantity</h6>   
<!-- {{ $room->quantity }} -->
	  <span id="roomQty" class="text-muted"></span>


	  var price=room->price;// i dont know how to assign ($price Value) 
          var noDate=diffDate; // i dont know how to assign ($diffDate  value)
	   var qty = $("#qty").val();
                url: "{{route('')}}?qty="+qty,
                type: 'GET',
                success: function (res){
   });// ajax 

any help please

Please sign in or create an account to participate in this conversation.