如何在PostBack之后运行客户端函数(JQuery / JavaScript)

时间:2015-04-22 02:25:22

标签: javascript jquery html asp-classic postback

我是jQuery和JavaScript的新手。

我有一个Html页面。有一个带有Method="Post"的表单,我有一个JavaScript函数。

在服务器端,我使用ASP classic。

我需要post我的表单Submit Button,并在提交并加载我的页面后,运行JavaScript方法。

这是一个示例:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>..........</title>
    <style>
       ...........
    </style>
<script>
    function initialize() {
    .....
    }
</script>
<body>
    <div style="height:250px">
        <form id="form1" runat="server" method="Post">

            <input type="radio" name="sex" value="male" checked>Male
            <br>
            <input type="radio" name="sex" value="female">Female
            <br>
            First name:<br>
            <input type="text" name="firstname">
            <br>
            Last name:<br>
            <input type="text" name="lastname">
            <br>
            <input type="submit" value="Ok" />
        </form>
    </div>
    <div id="map-canvas"></div>
</body>
</html>

我需要在PostBack运行initialize方法

之后

我使用这个JQuery但它不起作用。

<script>
    $(document).ready(function () {
        $.ajax({
            url: "ISPostBack.html",
            context: document.body
        }).done(function () {
            initialize();
        });
    });

</script>

我该怎么做?

1 个答案:

答案 0 :(得分:0)

你可以看一下https://api.jquery.com/jQuery.ajax/使用ajax来请求

相关问题