magnesium 发表于 2013-1-23 02:53:43

从头开始学JavaScript(第六天)

第六天学习的内容有:


1.Date类其中方法有:getMonth(),getDate(),getFullYear();

2.数组的sort()方法

3.string类其中的属性有:length
            其中的方法有:indexOf(),charAt(),tolowerCase(),toUpperCase()

4.math类   其中的属性有:PI
         其中的方法有:round(),floor(),ceiling(),random()

5.this用来把function转化为method

6.JavaScript创建类方式:

function Blog(body,date){
      
   this.body =body;
   this.date =date;


   this.toString()=function(){
   }


}

7.prototype用来声明和获得类变量和类方法(不是实例)

8.声明类方法:类名.方法名=function(){}




----------ajax--------------
9.readyState:0,1,2,3,4,5

10.status:200,404

11.创建xmlhttprequest对象
   var request = null;
   if(window.XMLHttpRequest){
      try{
      request = new XMLHttpRequest();
      }catch(e){
      request = null;
      }
   else if(window.ActiveXObject){
      try{
      request = new ActiveXObject("Msxml2.XMLHttp");
      }catch(e){
      try{
          request = new ActiveXObject("Microsoft.XMLHTTP");
      }catch(e){
      request = null;
      }
   }
   }

12.request.onreadystatechange = 自定义回调方法(注意:只要写方法名不需要括号)
   request.open(type,url,true)
            type:1.get:不改变服务器上数据时使用
               2.post:要改变服务器上数据时使用

   request.send()方法只有1个参数,就是要传到server的数据,如果url后已经拼接过数据
   则只要传入null就可以了

13.function updatePage() {
   if (request.readyState == 4)
       if (request.status == 200)
         alert("Server is done!");
   }
============================完===========================
页: [1]
查看完整版本: 从头开始学JavaScript(第六天)