im trying to show modal by sending the data from controller to view, but the modal is not shown, I don’t know what wrong, can anyone help me?
here is the code:
controller submit:
if ($success) {
return view('pages.approval.modal_ap', [
'post_ap' => $postap,
]);
}
index view:
$('#submit_app').on('click', function(event){
event.preventDefault();
$.ajax({
url: "{{ route('submit_approval') }}",
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(data_submit){
console.log(data_submit);
if (data_submit== "S") {
console.log("masuk modal");
$('#post_ap').modal('show');
$('#post_ap .btn-primary').on('click', function () {
$('#post_ap').modal('hide');
setTimeout(function () {
location.reload();
}, 1000);
});
}
modal view:
<div class="modal fade" tabindex="-1" id="post_ap">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Success</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-6 col-md-6 col-lg-6">
<div class="row mb-3">
<div class="col-lg-4">Document Number</div>
<div class="col-lg-8"><b>{{ $post_ap['tes'][0]->a }}</b></div> <!-- Akses dengan -> -->
</div>
<div class="row">
<div class="col-lg-4">Document Date</div>
<div class="col-lg-8"><b>{{ date('d.m.Y', strtotime($post_ap['tes'][0]->b)) }}</b></div> <!-- Akses dengan -> -->
</div>
<div class="row mb-3">
<div class="col-lg-4">Reference</div>
<div class="col-lg-8"><b>{{ $post_ap['tes'][0]->c }}</b></div> <!-- Akses dengan -> -->
</div>
<div class="row mb-3">
<div class="col-lg-4">Currency</div>
<div class="col-lg-8"><b>{{ $post_ap['tes'][0]->d }}</b></div> <!-- Akses dengan -> -->
</div>
<div class="col-sm-6 col-md-6 col-lg-6">
<div class="row mb-3">
<div class="col-lg-4">Company Code</div>
<div class="col-lg-8"><b>{{ $post_ap['tes'][0]->e }}</b></div> <!-- Akses dengan -> -->
</div>
<div class="row mb-3">
<div class="col-lg-4">Posting Date</div>
<div class="col-lg-8"><b>{{ date('d.m.Y', strtotime($post_ap['tes'][0]->f)) }}</b></div> <!-- Akses dengan -> -->
</div>
</div>
<div class="col-lg-4">
<div class="row">
<div class="col-lg-4">Fiscal Year</div>
<div class="col-lg-8"><b>{{ $post_ap['tes'][0]->g }}</b></div> <!-- Akses dengan -> -->
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-12 table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>CoCd</th>
<th>PK</th>
<th>TX</th>
<th>Account</th>
<th>Description</th>
<th>Amount</th>
<th>Curr</th>
<th>Profit Ctr</th>
<th>Segment</th>
<th>Text</th>
<th>Assignment</th>
<th>Cost Ctr</th>
</tr>
</thead>
<tbody>
@foreach($post_ap['a'] as $index => $t)
@php
$acc = '';
$desc = '';
if (trim($t->LIFNR) == '') {
$acc = trim($t->z);
foreach ($post_ap['t_skat'] as $skat) {
if (trim($skat->s) == 'E' && trim($skat->h) == 'DPCA' && trim($skat->f) == $acc) {
$desc = trim($skat->u);
break;
}
}
} else {
$acc = trim($t->l);
foreach ($post_ap['t_lfa1'] as $lfa1) {
if (trim($lfa1->q) == $acc) {
$desc = trim($lfa1->g);
break;
}
}
}
@endphp
<tr>
<td>{{ ltrim($t->b, '0') }}</td>
<td>{{ $t->b }}</td>
<td>{{ $t->b }}</td>
<td>{{ $t->b }}</td>
<td>{{ trim($acc, '0') }}</td>
<td>{{ $desc }}</td>
<td>
@if (trim($t->b) == 'H')
-
@else
@if ($t->b == 'DNPA')
{{ number_format($t->b, 2, '.', ',') }}
@else
{{ number_format($t->b * 100, 0, '.', ',') }}
@endif
@endif
</td>
<td>{{ $t->b }}</td>
<td>{{ ltrim($t->b, '0') }}</td>
<td>{{ $t->b }}</td>
<td>{{ $t->b }}</td>
<td>{{ $t->b }}</td>
<td>{{ ltrim($t->b, '0') }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
{{-- @endif --}}
<div class="modal-footer">
<button type="button" class="btn btn-primary">OK</button>
</div>
</div>
</div>
</div>
the console.log(“masuk modal”) is call but the modal is not show
I already try to call modal with just empty html and it works
and I also try to console log the modal
console.log("masuk modal");
console.log($('#post_ap').modal('show'));
and it send this
can anyone help me, I don’t know whats wrong