Is there any way to submit the form to server for an AJAX response without reloading the page. I am able to do this with submit button. But how can I do that when a link is clicked.
I came to know about a javascript method to do this,
var form = document.getElementById('myForm');
form.submit();
But the above code reloads the page. I came to know that we can do this with jquery but how?
Please Note that I am developing my application in Ruby on Rails 3.0.4 and I am using the rails AJAX like this.
<%= form_for @search, :remote => true, :url => request_path, :html => {:method => :get, :id => :my_form} do |f| %>
Any help would be appreciated.
I got it working by just using this code. No need to define a function inside submit.