I am having many submit buttons one for each row in a table. Whenever I click on that button, an Ajax call should be triggered. Right now I am wrapping each button inside a form tag. Is this a good approach? If not, what is a better way to do this.
Moreover, I will be replacing the button eventually by an image.
Please advise on how to handle this situation.
Yes, this is fine.
The only problem is that the HTML is a little on the chunky side, but that issue is largely eliminated by gzip compression (since there will be a lot of duplicate tokens, which are highly compressible).
In its favour, the method is very simple to implement, very hard to go wrong, and doesn’t depend on the user having JavaScript turned on.
You can then, with very little effort, enhance the forms with onsubmit events to use JavaScript to send the data using Ajax and cancel the normal submission of the form.
I would generally try to avoid that. A button is a clear indicator that it is something clickable that will do something. If you really want to, you can substitute the submit input for an image input.