I have ajax code in rails 3 that is not responding in contoller.. here the code goes...
<%= javascript_include_tag "application" %>
<script type="text/javascript">
function fetching(){
var data=document.getElementById('parent_type').value
if(data){
req = new Ajax.Request('/registrations/select_type/1', {
method: 'get',
parameters: { data : data},
onComplete: function(transport) {
processReqChange(transport);
}
}); // end ajax req
}
}
</script>
and in registration controller--
def select_type
raise "hiiiiiiiiiiiiiiii".inspect
render :js =>"document.getElementById('parent_lname').value='jyothi';"
end
here it is not raising "hiiii" it means ajax request is not calling
In your registrations controller you should have a respond_to block
respond_to do |format|
format.js {render :js =>"document.getElementById('parent_lname').value='jyothi';"}
end
for further reading
http://apidock.com/rails/ActionController/MimeResponds/respond_to