【发布时间】:2020-12-25 00:29:47
【问题描述】:
这是两个选择框。当我同时选择产品和保修值时,它应该传递给控制器。那么我应该如何传递?
<select id="products">
<option value="1">Mobile</option>
<option value="2">Laptop</option>
</select>
<select id="warrant">
<option value="1">1 Years</option>
<option value="2">2 years</option>
<option value="3">3 years</option>
</select>
这是我的脚本文件
$('#products').change(function () {
var product_id=$(this).val();
})
$('#warrant').change(function () {
var warrant_id=$(this).val();
})
我想在下面的代码中传递 Controller 中的那些warrant_id 和 product_id 那么我该如何传递呢?
<script>
fetch('http://127.0.0.1:8000/api/productChart'+{
warrant_id,product_id
})
.then(response => response.json())
.then(data => {
this.sales = data.sales;
this.start = data.start;
this.to = data.end;
});
</script>
这是我的路线
Route::get('/productChart','Controller@productChart');
【问题讨论】:
-
目前两者都没有通过?
-
@AlwaysHelping nope 我只是在尝试。但是我怎么能呢?
标签: javascript jquery laravel api