get the current function name in javascript

Viewed 16073

I have this piece of code:

function MyFunction()
{
    $.ajax({
        type: "POST",
        url: "ajax.php",
        dataType: "json",
        data: "foo=bar",
        error:function(XMLHttpRequest, textStatus, errorThrown)
        {
            alert(arguments.callee);
        },
        success: function(jsonObject)
        {
            //do something
        }
    });
}

what I want is that the alert inside de error scoope shows the function name, in this case "MyFunction" but instead what I get is the error:function.

How can I achieve this?

7 Answers
Related