Rails jQuery意外令牌“<”
我的代码是
应用程序/视图/间/ photo_upload.html.slim
.panel-body .container .row .col-md-offset-3.col-md-6 = form_for @room, url: room_photos_path(@room), method: "post", html: {multipart: true} do |f| .row .form-group span.btn.btn-default.btn-file.text-babu i.fa.fa-cloud-upload aria-hidden='true' | Select Photos = file_field_tag "images[]", type: :file, multiple: true .text-center = f.submit "Add Photos", class:"btn btn-form" #photos = render "photos/photos_list"
应用程序/视图/照片/ _photos_list.html.slim
- if @photos.count > 0 br/ br/ .row - @photos.each do |photo| .col-md-4 .panel.panel-default .panel-heading.preview = image_tag photo.image.url() .panel-body span.pull-right = link_to room_photo_path(photo.room_id, photo), remote: true, method: :delete, data: {confirm: "are you sure?"} do i.fa.fa-trash-o aria-hidden="true"
photos_controller.rb
def destroy @photo = Photo.find(params[:id]) room = @photo.room @photo.destroy @photos = Photo.where(room_id: room.id) respond_to :js end
应用程序/视图/照片/ destroy.js.erb
$('#photos').html("")
这是我在尝试从列表中删除照片时遇到的错误。
Uncaught SyntaxError: Unexpected token < at processResponse (rails-ujs.self-817d9a8cb641f7125060cb18fefada3f35339170767c4e003105f92d4c204e39.js?body=1:246) at rails-ujs.self-817d9a8cb641f7125060cb18fefada3f35339170767c4e003105f92d4c204e39.js?body=1:173 at XMLHttpRequest.xhr.onreadystatechange (rails-ujs.self-817d9a8cb641f7125060cb18fefada3f35339170767c4e003105f92d4c204e39.js?body=1:230)
我得到的回应就是这个
AirBnbClone