I have to populate the checkboxes on a page from the database. I am using an AJAX get method for fetching the record ID and it's corresponding right in a hash,

CoffeeScript:

$ ->
$(document).ready ->
 $.get('/server_management/getpair/').success (data) ->
   alert(data.toString()) # Shows nothing
   console.log(data) # Shows the HTML of the entire page

Controller:

 def getpair

 pair = UserServer.getpair
 render :nothing => true

 end

Model:

 def self.getpair

 UserServer.find_each do |us|
    if us.user_id == @uid # @uid is getting its value in another UserServer method
       pair[us.server_id] = us.right
    end
 end
 gair = pair # Just for the sake of 'last-assignment-is-a-return-in-ruby' thingy

 end

Now the problem is that the AJAX get is showing "Status Code:304 Not Modified" and the console.log(data) shows the HTML of the page.

I will be grateful for any help.

Related posts

Recent Viewed