如何从该函数内部访问函数名称? // parasitic inheritance var ns.parent.child = function() { var parent = new ns.parent(); parent.newFunc = function() { } return parent; } var ns.parent = function() { // at this point, i want to know who the child is that called the parent // ie } var obj = new …
有没有办法将更多数据传递到jQuery中的回调函数中? 我有两个函数$.post,例如,我希望回调到,以传递AJAX调用的结果数据以及一些自定义参数 function clicked() { var myDiv = $("#my-div"); // ERROR: Says data not defined $.post("someurl.php",someData,doSomething(data, myDiv),"json"); // ERROR: Would pass in myDiv as curData (wrong) $.post("someurl.php",someData,doSomething(data, myDiv),"json"); } function doSomething(curData, curDiv) { } 我希望能够将自己的参数以及AJAX调用返回的结果传递给回调。