我的Js和AJAX代码有什么问题?我在select_tag上使用ajax和JS,并在ajax中得到错误;
- @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;
});
});
});发布于 2014-11-23 03:20:41
在数据中添加}
data: {collocation_request_department: {reviewer: $(this).val()}},https://stackoverflow.com/questions/27085221
复制相似问题