javascript触发jquery html()ajax插入

I am inserting the following javascript function into my page using the jQuery command html(data_in_here). How do I make it run the javascript code?

        echo 'window.onload = function(){';
            echo 'var ctx = document.getElementById("canvas").getContext("2d");';
            echo 'window.myLine = new Chart(ctx).Line(lineChartData, {';
                echo 'responsive: true,';
                echo 'maintainAspectRatio: false';
            echo '});';
        echo '}';

I assume it's not running because it is using window.onload?