Sunday, May 19, 2024
64
rated 0 times [  68] [ 4]  / answers: 1 / hits: 15911  / 11 Years ago, thu, june 27, 2013, 12:00:00

I am trying to make an ajax call to my controller



class PatientRecordController < ApplicationController
def export
....
end
end


In my javascript file i have



$(document).ready(function(){
freezeTopRow($('#dataTable'));
$(#export).click(function(){
$.ajax({url: patient_record/export, type: POST});
});
});


when i inspect element and debug and when i click the export tag on my page. i hit the function however it never gets to the controller



Also I have 2 controllers and 2 views. In my other controller and view I do the same thing and it works


More From » ruby-on-rails

 Answers
20

Have you checked that you routes.rb have something like:



post 'patient_record/export'


Maybe Rails doesn't know the route so the ajax isn't working (if you can get to the action from your browser it means that you have only a GET set, you can check that changing the type of the request in the ajax call)


[#77369] Wednesday, June 26, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zaynerogerb

Total Points: 454
Total Questions: 109
Total Answers: 97

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
zaynerogerb questions
;