I need to submit a form via ajax with prototype.js unobtrusively. How do I unobtrusively attach the script to submit with prototype? I've done it with jQuery before, but I need to use prototype on this one. Basically I need to do with prototype.js what the below script does with jquery.js. I would appreciate any help.
| Code: |
|
$(function() { // onload...do $('#contestForm').submit(function() { var inputs = []; $(':input', this).each(function() { inputs.push(this.name + '=' + escape(this.value)); }) jQuery.ajax({ data: inputs.join('&'), url: this.action + '?type=ajax', timeout: 2000, error: function() { console.log("Failed to submit"); }, success: function(r) { jQuery.facebox(r); } }) return false; }) }) |
