zoukankan      html  css  js  c++  java
  • ajax get,post提交數據

    //ajaxRead("http://page.aspx?aa=jj&bb=3434",post);

    function ajaxRead(file,type){
      var xmlObj = null;
      if(window.XMLHttpRequest){
          xmlObj = new XMLHttpRequest();
      } else if(window.ActiveXObject){
          xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
      } else {
          return;
      }
      xmlObj.onreadystatechange = function(){
        if(xmlObj.readyState == 4){

            //回調函數
            callback(xmlObj.responseText);
         }
        }

        if(file.indexOf("?")>-1)
        {
            file+="&r="+Math.random();
        }
        else
        {
            file+="?r="+Math.random();
        }    
        
        switch(type.toUpperCase())
        {
            case "GET":
                xmlObj.open ('GET', file, true);
                xmlObj.send (null);
                break;
            case "POST":
                xmlObj.open("POST",file,true);
                xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
                var querystring=file.substr(file.indexOf("?")+1);
                xmlObj.send(querystring);
                break;
             default:
                 break;
        }
      }


      function callback(response)
      {
        //返回值的處理
        alert(response);
      }
  • 相关阅读:
    Java/IO流
    Java实现IO通信(服务器篇)
    利用哈夫曼二叉树实现文件的压缩
    关于字符串构建,连接,查找
    线程小球
    准备造一个轮子,关于图片浏览器的
    IOS之循环引用
    ARC
    构造方法与快速创建对象
    autorelease
  • 原文地址:https://www.cnblogs.com/wang123/p/1125032.html
Copyright © 2011-2022 走看看