直接上扩展的代码
$.extend({ StandardPost:function(url,args){ var form = $("<form method='post'></form>"), input; form.attr({"action":url}); $.each(args,function(key,value){ input = $("<input type='hidden'>"); input.attr({"name":key}); input.val(value); form.append(input); }); form.submit(); } });
简单的调用
$.StandardPost('url/path/req',{arg0:'arg0',arg1:'arg1'});