我的Js和AJAX代碼有什麼問題?我在select_tag上使用ajax和JS,並且出現ajax錯誤;select_taf上的Ajax和JS; SyntaxError:missing}屬性列表後
- @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;
});
});
});
你得到,上面寫着「缺}」,因爲你的代碼丟失的錯誤是「}」上的「數據:」行了ajax參數。什麼不清楚? – Pointy 2014-11-23 03:19:19
我添加了缺少的部分。 JS正在工作,但PUT功能不是。不知道爲什麼 – Kourosh 2014-11-23 11:05:39