我正在使用laravel框架和构建系统,其中用户输入标准,并从数据库中获得所有数据,这与他们在表中的搜索标准相匹配。在结果表的每一行数据中都有一个名为"request“的链接。用户单击请求链接以请求所需的项目。请求链接将特定项的in传递到后端,并更新到数据库中的表列。目前,页面每次都必须重新加载才能发出请求,这是相当烦人的。那么,我可以在不使用ajax刷新页面的情况下,通过链接动态地将i传递到我的后端吗?
这是我的观点
<div class='container' style="margin-top:50px">
<div class="row">
<div class="input-group" style="margin:20px">
<form >
<table style="float:right">
<th>
<div class="form-outline">
<input type="search" id="form1" class="form-control" placeholder="Search" /></th>
<th><button type="button" class="btn btn-success" >
<i class="fas fa-search"></i>
</button></th>
</form>
</div>
<div class="table-responsive">
<table class="table custom-table">
<thead>
<tr>
<th scope="col">
<label class="control control--checkbox">
<input type="checkbox" class="js-check-all"/>
<div class="control__indicator"></div>
</label>
</th>
<th scope="col" >S.N</th>
<th scope="col">LC NO</th>
<th scope="col">Applicant</th>
<th scope="col">Doc Value</th>
<th scope="col">Doc Received date</th>
<th scope="col">LC Type</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php $number = 1;?>
@foreach($datas as $items)
<tr>
<th scope="row" style="padding:20px">
<label class="control control--checkbox">
<input type="checkbox"/>
<div class="control__indicator"></div>
</label>
</th>
<td>{{$number}}</td>
<td>{{$items->lc_no}}</td>
<td>{{$items->applicant}}</td>
<td>{{$items->doc_value}}</td>
<td>{{$items->rec_date}}</td>
<td>{{$items->sight_usance}}</td>
<td><a href="maturity_reqController/{{$items->id}}">Request</a></td>
<td><a href="/hold_req/{{$items->id}}">Hold</a></td>
</tr>
<?php $number++; ?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
这是我的控制器
function maturity_reqController($id){
$forset = new Settlement();
$forset->org_document_id = $id;
$forset->save();
$data = Doc::find($id);
$data->status = "Maturity Requested";
$data->save();
return redirect('maturity_settlement');
}
发布于 2021-06-04 01:11:45
如下所示更改链接
<td><a href="#" data-id="{{$items->id}}" class="sendRequest">Request</a></td>
在javascript中
<script>
$('.sendRequest').on('click',function(){
var id=$(this).attr('data-id')
$.ajax
({
type: "GET",
url: "maturity_reqController/"+id,
success: function(response)
{
alert(response);
}
});
})
</script>
https://stackoverflow.com/questions/67825586
复制相似问题