开发者

jQuery $.get and Rails

开发者 https://www.devze.com 2023-01-22 19:44 出处:网络
I have a script that makes an Ajax call to one of my rails resources to grab all the notes for a particular page.

I have a script that makes an Ajax call to one of my rails resources to grab all the notes for a particular page.

Rails Controller:

def show
    if request.xhr?
      @page = Page.find(params[:page_id])
      @note = Note.find_by_page_id(params[开发者_如何学编程:page_id])
      @user = User.where("user_id = ?", @note.user_id)
    end
  end

jQuery $.get ajax:

function viewNotes(page_id){
            $.get('/pages/' + page_id + '/notes', function(data){
                $("#note_content").html(data);
            });
        }

I am getting this error Uncaught Error: NOT_FOUND_ERR: DOM Exception 8 (I am using Google Chrome for testing)

Any ideas on why this error would occur?


Try printing the "data" variable to the console to make sure that it has the proper contents. The jQuery looks valid to me.

0

精彩评论

暂无评论...
验证码 换一张
取 消