开发者

Embedded HTML contains JavaScript function not getting called

开发者 https://www.devze.com 2023-03-09 03:32 出处:网络
In my scenario i am making an ajax request to get some data and then passing its result to some function you can see the code.

In my scenario i am making an ajax request to get some data and then passing its result to some function you can see the code.

    $.ajaxSetup({ cache: false });
    $.ajax({
        url: chartUrl,
        type: 'GET',
        dataType: 'text',
        success: function(result){
            UpdateChartArea(result, chartType);
            if(isTextMining){               
                         eval('ShowBreadCrmb_'identifier.substring(1) + '();');
            }
        },
        error: function(req, status, error) {

        }
    });

After embedding the HTML i want to call a JS function that is in that HTML. the HTML that i am embedding is present in a user control so to have a unique instance this is how my show bread crumb method look like

    function ShowBreadCrmb_<%= reportScale.ScaleID %>()
    {
    alert('LHJLH');
        var isTextMining = <%= TextMiningChart %>;
        if(isTextMining)
        {
            CreateTmBreadCrumb('<%= reportScale.NodeLevel %>','<%= reportScale.NodeName %>',topicList)
        }
    }

for more i开发者_高级运维nfo what my updatechartarea does is

if (parent) {
    clearChildren(parent);
    var div = document.createElement("div");
    div.innerHTML = html;
    parent.appendChild(div);
}

I want to call the bread crumb function after update chart area function is called.


I would just change the function definition of ShowBreadCrmb_... to include parentheses after the closing bracket }. That should invoke it right after defining it.

e.g.

function ShowBreadCrmb_<%= reportScale.ScaleID %>()
{
alert('LHJLH');
    var isTextMining = <%= TextMiningChart %>;
    if(isTextMining)
    {
        CreateTmBreadCrumb('<%= reportScale.NodeLevel %>','<%= reportScale.NodeName %>',topicList)
    }
}();

Does that work?

0

精彩评论

暂无评论...
验证码 换一张
取 消