如何在页面加载时调用javascript函数 [英] how to call javascript function on page load

查看:76
本文介绍了如何在页面加载时调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function getMoreNewsItems(url) {
    $.ajax({
        type: "POST",
        url: url,
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
        }
    });
}


getMoreNewsItems('<%= ResolveUrl("headlinenews/loadFeedBellaNaija") %>')

getMoreNewsItems('<%= ResolveUrl("headlinenews/loadFeedChannelsTV") %>')

getMoreNewsItems('<%= ResolveUrl("headlinenews/loadFeedNaijaLoaded") %>')




    [WebMethod]
    private static void loadFeedBellaNaija()
    {

    }

    [WebMethod]
    private static void loadFeedChannelsTV()
    {

    }

    [WebMethod]
    private static void loadFeedNaijaLoaded()
    {

    }



i am using VS 2010 with the new routing functionality, i am new to javascript!
how can i call getMoreNewsItems on page load

。或者我在这里做正确的事吗?

.Or am i doing the right thing here?

推荐答案

.ajax({
类型:POST,
url:url,
数据:{},
contentType:application / json; charset = utf-8,
dataType:json,
成功:函数(msg){
alert(msg.d);
}
});
}


getMoreNewsItems('<% = ResolveUrl( headlinenews / loadFeedBellaNaija%> ')

getMoreNewsItems('<% = ResolveUrl( headlinenews / loadFeedChannelsTV%> ')

getMoreNewsItems('< % = ResolveUrl( headlinenews / loadFeedNaijaLoaded%> ')




[WebMethod]
private static void loadFeedBellaNaija()
{

}

[WebMethod]
private static void loadFeedChannelsTV()
{

}

$ b [WebMethod]
私有静态void loadFeedNaijaLoaded()
{

}



我正在使用具有新路由功能的VS 2010,我是javascript的新手!
如何在页面加载时调用getMoreNewsItems
.ajax({ type: "POST", url: url, data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert(msg.d); } }); } getMoreNewsItems('<%= ResolveUrl("headlinenews/loadFeedBellaNaija") %>') getMoreNewsItems('<%= ResolveUrl("headlinenews/loadFeedChannelsTV") %>') getMoreNewsItems('<%= ResolveUrl("headlinenews/loadFeedNaijaLoaded") %>') [WebMethod] private static void loadFeedBellaNaija() { } [WebMethod] private static void loadFeedChannelsTV() { } [WebMethod] private static void loadFeedNaijaLoaded() { } i am using VS 2010 with the new routing functionality, i am new to javascript! how can i call getMoreNewsItems on page load

。或者我在这里做正确的事吗?

.Or am i doing the right thing here?


Page.RegisterStartupScript("OnLoad","<script>functionName();</script>");


ClientScript.RegisterStartupScript(GetType(), "key", "getMoreNewsItems();", true);



参考:

http://stackoverflow.com/questions/3084853/calling-javascript-at-page-load [ ^ ]

http://www.codeproject.com/Messages/2558205/Re-call-javascript-function-on- Pageload-asp-net-wi.aspx [ ^ ]

希望这可能会有所帮助。


Refer:
http://stackoverflow.com/questions/3084853/calling-javascript-at-page-load[^]
http://www.codeproject.com/Messages/2558205/Re-call-javascript-function-on-Pageload-asp-net-wi.aspx[^]
Hope this may help.


这篇关于如何在页面加载时调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆