If you look at the code inside the #top_cat
and #high_hat
sections below, it's obvious that it does the same thing.
$(document).ready(function ()
{
$('#top_cat').submit(function ()
{
$.post($(this).attr('action'), $(this).serialize(), null, "script");
return false;
});
$("#tip_click").click(function()
{
$("#high_hat").submit()(function ()
{
$.post($(this).attr('action'), $(this).serialize(), null, "script");
return false;
});
return false;
});
});
What's the correct syntax to separate the inner code (below) into its own function so that it's callable inside the #top_cat
and #high_cat
sections without the duplication that exists above?
$.post($(this).attr('action'), $(this).serialize(), null, "script");
return false;