日期:2014-05-17  浏览次数:20360 次

asp.net jquery问题

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
    <script>

        function aa() {
            $.post("Handler1.ashx", {}, function (date) {
                $("#st").val('1');
            });
            alert($("#st").val());
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a onclick="aa();">adsfasf</a>
    <input runat="server" type="hidden" id="st" />
    </div>
    <asp:Button ID="Button1" runat="server" OnClientClick="aa();"  Text="Button" />
    </form>
</body>
</html>alert($("#st").val());第一次alert为空,第二次才有值,什么情况,怎么解决呢?

------解决方案--------------------
 function aa() {
            $.post("Handler1.ashx", {}, function (date) {
                $("#st").val('1');
            });
            alert($("#st").val());
        }
=>
 function aa() {
            $.post("Handler1.ashx", {}, function (date) {
                $("#st").val('1');