ok, seems like i got it on my own, with a bunch of help from malsup's blog and the jq docs.
looks like that. that's ok, you think? (function($) { jQuery.fn.jsonForm = function(options) { var opts = $.extend({}, $.fn.jsonForm.defaults, options); return this.each(function(){ jQuery(this).ajaxForm({ type: "json", success: function(data){ // private implementation here ... opts.success(data); } }); }); }; $.fn.jsonForm.defaults = { success: function(){} }; })(jQuery); On Feb 9, 5:20 pm, Jan Limpens <jan.limp...@gmail.com> wrote: > When I try to do this, firebug does not alert me of anything wrong, > the form is posted normally (no ajax). > What mistake am I making? > > // requires jquery.forms plugin > jQuery.fn.jsonForm = function(onSuccess) { > this.ajaxForm({ > dataType: 'json', > success: function(data) { > if (data.Message) { > alert(data.Message); // my json reply always has these 2 > fields > } > if (data.ActionUrl != null) { > top.location = data.ActionUrl; > } > if (onSuccess != null) { > onSuccess(data); // what if onSuccess has an empty > signature? > } > } > > }); > } > > So I can call it like so: > > var onSuccess = function(data){ > $.each(data.Customer, function(i, item){ > $('#searchResultCustomers').append("<dd>"+ item.Name > +"</dd>"); > }); > }); > $('.jsonFormCustomer').jsonForm(onSuccess); > > How could I call jsonForm without a null param, too? > > Help greatly appreciated!