Execute dynamic function with param in javascript

Posted by Valamas on Stack Overflow See other posts from Stack Overflow or by Valamas
Published on 2012-09-13T03:18:02Z Indexed on 2012/09/13 3:39 UTC
Read the original article Hit count: 196

Filed under:

if the following possible? I wish to move the alert(result) into a function and to dynamically call it.

Current

$.ajax(this.href, {
    success: function (result)
    {
        alert(result);

        AjaxComplete();
    }
});

My Attempt - not working

$.ajax(this.href, {
    success: function (result)
    {
        window["MyAlert(result)"]();

        AjaxComplete();
    }
});

function MyAlert(result)
{
    alert(result);
}

Is this possible?

© Stack Overflow or respective owner

Related posts about JavaScript