我需要设置一个事件处理程序,其工作是返回正在设置处理程序的函数,而不是匿名触发器处理程序本身。如何做到这一点?请看下面的代码:
if(subFormToServer())
doSuccessDance();
else
doErrorStuff();
function subFormToServer(thaGoods) {
$('<iframe name="subform-target" style="display: none;"></iframe>')
.bind('load', function(){ return 0; }) // how to I "pass" these return statements "up" to my function or "escape" them, so to speak, so that what they're returning isn't the load/error handler functions, but actually the subFormToServer function?
.bind('error', function(){ return 1; })
.appendTo('body');
$('<form method="POST" '+
'action="http://server/formHandler.php" '+
'target="subform-target"> '+
'<input name=inputName value="'+encodeURIComponent(thaGoods)+'">'+
'</form>')[0]
.submit();
}