六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 49|回复: 0

从头开始学JavaScript(第六天)

[复制链接]

升级  52%

6

主题

6

主题

6

主题

童生

Rank: 1

积分
26
 楼主| 发表于 2013-1-23 02:53:43 | 显示全部楼层 |阅读模式
第六天学习的内容有:


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!");
   }
============================完===========================
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表