【发布时间】:2022-01-03 14:50:35
【问题描述】:
您好,我目前正在处理模式内的切换(活动 - 非活动)。 我能够使其工作,将活动变为非活动。但是,将其恢复为活动将不起作用,并且状态保持为非活动状态。
我怎样才能做到这一点?这里缺少什么?
提前致谢
这是我的 JS
$("#updatetaxform").on('submit', function (e) {
e.preventDefault()
const pid = $("#updatetaxform [name=pid]").val();
const IsActive = $("#updatetaxform").prop('checked') == true ? 1 : 0;
$.ajax({
data: {
pid,
IsActive
},
url: "/edit-tax",
type: "POST",
success: function (data) {
console.log(data.success)
var oTable = $('#tax-info-table').dataTable()
oTable.fnDraw(false)
Swal({
type: 'success',
title: 'Success!',
text: "Successfully updated!",
showConfirmButton: false,
timer: 3000
}).then(function () {
location.reload()
})
},
error: function (data) {
console.log('Error:', data.responseJSON.message);
Swal({
type: 'error',
title: 'Tax Information Error',
text: data.responseJSON.message
})
}
}) })
这是我的输入 html
<div class="form-group">
<label for="">Active Status</label>
<input type="checkbox" data-toggle="toggle" data-onstyle="success" data-offstyle="danger" data-style="ios slow" data-width="100" data-height="20" name="IsActive" {{ $taxstatus->IsActive ? 'checked' : ''}}>
</div>
这是我的控制器
public function editTax(Request $request)
{
$tax = TaxDetails::where('id', $request->id)->update(
['pid' => $request->pid, 'IsActive' => $request->IsActive ]
);}
public function index()
{
$tax1 = TaxDetails::where('pid', Session::get('pid'))->first();
return view('pages.tax-information', [
'taxstatus' => $tax1
]);
}
【问题讨论】:
标签: javascript laravel laravel-5