【发布时间】:2017-05-17 14:35:50
【问题描述】:
我正在使用以下 URL http://localhost/npr/public/admin/athletes/test/143 处理屏幕
在此屏幕上,我实现了以下未找到的动态下拉列表 Ajax 调用:
$(document).ready(function() {
$('select[name="section"]').on('change', function() {
var sectionID = $(this).val();
if(sectionID) {
$.ajax({
url: './getSportPositions'+sectionID,
method: 'get',
//data: {"_token": $('#token').val()},
dataType: "json",
success:function(data) {
$('select[name="position"]').empty();
$('select[name="position"]').append('<option value="">'+ '-- Please choose one --' +'</option>');
$.each(data, function(i, position) {
$('select[name="position"]').append('<option value="'+position.name+'">'+ position.name +'</option>');
});
}
});
}else{
$('select[name="position"]').empty();
}
});
});
路线:
Route::get('getSportPositions{id}','HomeController@getSportPositions');
我也试过:
Route::get('/admin/athletes/test/getSportPositions{id}','HomeController@getSportPositions');
是由于调用 URL 中的运动员 ID 143 造成的吗?我该如何解决这个电话? 从错误看来,它正在尝试访问此路由:
Route::get('/admin/athletes/test/{athlete}/', [
'uses' => 'HomeController@testAnAthlete',
'as' => 'admin.test_athlete'
]);
HTML:
<div class="form-group {{ $errors->has('position') ? ' alert alert-danger' : '' }}">
<label for="position" class="col-md-3 control-label">Position in Team</label>
<div class="col-md-6">
<select class="form-control" name="position" id="position">
@if (!$errors->has('position'))
<option selected value> -- select a team first -- </option>
@endif
</select>
</div>
@if ($errors->has('position'))
<span class="help-block">
<strong>{{ $errors->first('position') }}</strong>
</span>
@endif
</div>
【问题讨论】:
-
请添加选择html代码