zoukankan      html  css  js  c++  java
  • ajax的post提交

        <script language="javascript">
            var xmlHttpRequest = null;
            function selectionChanged() {
                // IE only.
                xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                string = "objstr=1";
                //发送数据
                xmlHttpRequest.open("POST", "A.aspx", false);//提交到A.aspx
                xmlHttpRequest.setrequestheader("content-length", string.length);
                xmlHttpRequest.setrequestheader("content-type", "application/x-www-form-urlencoded");
                xmlHttpRequest.send(string);

                xmlHttpRequest.onreadystatechange=onReadyStateChange;
            }

            function onReadyStateChange() {
                if (xmlHttpRequest.readyState == 4) {
                    if (xmlHttpRequest.status == 200) {
                        var w= xmlHttpRequest.responseText;
                    }
                }
            }
        </script>

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/plain";

            string objstr= Request.Form["objstr"].ToString();


            Response.Write("Hello World"+objstr); 

            Response.End();
        }

    另外,AJAX是不支持跨域提交的,这应该是浏览器的权限的

  • 相关阅读:
    山寨 《寻找房祖名》
    css3 弹性效果上下翻转demo
    CSS3 Hover 动画特效
    判断一个字符串通过变化字符的位置,是否可以组成回文
    获取多个字符串中的共同字符
    转换为回文的步数
    IOS中图片的一些处理方法
    python django的一点笔记
    一个图片切割的例子
    一个批量修改文件夹中文件名的命令
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/1456979.html
Copyright © 2011-2022 走看看