Javascript 选择taf上的Ajax和JS;SyntaxError:属性列表后缺少}
我的Js和AJAX代码有什么问题?我在select_标签上使用ajax和JS,我在使用ajax时出错Javascript 选择taf上的Ajax和JS;SyntaxError:属性列表后缺少},javascript,jquery,ruby-on-rails,ajax,Javascript,Jquery,Ruby On Rails,Ajax,我的Js和AJAX代码有什么问题?我在select_标签上使用ajax和JS,我在使用ajax时出错 - @departments = @collocation_request.collocation_request_departments td Reviewer - @departments.each do |department| td div.input-append = select_tag
- @departments = @collocation_request.collocation_request_departments
td Reviewer
- @departments.each do |department|
td
div.input-append
= select_tag :reviewer_id, options_from_collection_for_select(User.where(department_id: department.department_id), "id","full_name"), prompt: 'Select a Reviewer', remote: true
javascript:
$(function(){
$(document).on('change','#reviewer_id',function(e) {
alert($(this).val());
var collocation_request_id = $(this).data('collocation-request-id');
var departments_id = $(this).data('department-id');
jQuery.ajax({
type: "PUT",
dataType: 'JSON',
data: {collocation_request_department: {reviewer: $(this).val()},
url: '/collocation_requests/'+collocation_request_id+'/departments/'+departments_id+'.js'
}).complete(function(data, textStatus, jqXHR) {
window.location = window.location;
});
});
});
在数据中添加
}
data: {collocation_request_department: {reviewer: $(this).val()}},
由于代码在ajax参数的“data:”行中缺少“}”,因此您将得到一个显示为“missing}”的错误。有什么不清楚的?我添加了缺少的部分。JS正在工作,但PUT函数不工作。不确定为什么JS和AJAX可以工作,但是PUT函数不能工作,下面是代码的另一部分: