jquery練習3筆記

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript">
       function check_email() {
           var email = $("#email").attr("value");
           $.post("han.ashx",
    { Email: email },
     function (data) {
         window.alert(data);
     });
 }
 $(document).ready(function () {
     $("#queren").click(function () { check_email(); });
 
 })
   </script>
 
</head>
<body>
<input type="text" id="email" />
<input id="queren" type="button" value="test" />
 
</body>
</html>
 
Han.ashx代碼
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write(context.Request["Email"]);
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
 
 
 
 
1、$("#email").attr("value")取得email文本框的值
2、要實現jquery ajax 需要在webconfig中添加
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
    <httpHandlers>
      <add verb="*" path="*.ashx" type="System.Web.UI.SimpleHandlerFactory" validate="false"/>
    </httpHandlers>
    </system.web>
3、
 
作者“技術學習筆記”

發佈留言