开发者

Load up javascript files after ajax call

Hi how do i go about loading up my javascript files after an ajax call has been made, reason being it seems once i click submit, some javascript functions do not end up working. I tried u开发者_如何转开发sing "$getscript" however it was a bit buggy especially in google chrome? This is what my call looks like;

function InsertStatus() {
    var fStatus1 = document.getElementById('<%=txtStatus.ClientID %>').value;

    $.ajax({
        type: "POST",
        url: "WebServices/UserList.asmx/InsertUserStatus",
        data: "{ 'fStatus': '" + fStatus1 + "' }",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            if (data.d == "Successful") {
                $("#col-3").load(location.href + " #col-3>*", "");
                $.getScript('scripts/script.js', function () {
                });
            }
            else {
                alert("its false");
                $.getScript('scripts/script.js', function () {
                });
            }
        }
    });
};


Replace $.getScript('scripts/script.js', function () {});

With:

$.ajax({
    dataType: 'script',
    url: 'scripts/script.js',
    crossDomain:true,
    success: function(response)
    {
        //Whatever
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜