I am new in rails 3
I want to use some count down in my view.
so I need some ajax query.
where will we write ajax code and how to use it in view?
Please help.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Any javascript functionality would be considered front-end. In rails or in a typical model-view-controller web framework, the view would be responsible to deal with any ajax or other javascript code. The best possible way of doing this, is having the view (a layout file, or action file) include a javascript file. Your javascript file would then have a function that would incorporate the ajax request. Your view should be the place to fire off the function. Just like an event system, the javascript would register the event (function), and the view would trigger that event. If it’s just a single ajax request then you could also leave out the trigger inside the view, and have a $(document).ready({…}) call inside your javascript file.