Ajax learning

1.For  FF and IE we can use:

========================

以支持多种浏览器的方式创建 XMLHttpRequest 对象

/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
    xmlHttp = false;
  }
}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();

}
=====================

2.open the url with :get or post

xmlHttp.open("GET", url, true);

If u want to use 'POST' like:

xmlHttp.open("POST", url, true);
U should add use like :
----------
  // Open a connection to the server
  xmlHttp.open("POST", url, true);
  // Setup a function for the server to run when it's done
  xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  //post method need this sentence
  xmlHttp.onreadystatechange = updatePage;
  // Send the request
  xmlHttp.send(postStr);
----------

3.Five Steps:五个步骤

=========

0:请求没有发出(在调用 open() 之前)。
1:请求已经建立但还没有发出(调用 send() 之前)。
2:请求已经发出正在处理之中(这里通常可以从响应得到内容头部)。
3:请求已经处理,响应中通常有部分数据可用,但是服务器还没有完成响应。
4:响应已完成,可以访问服务器响应并使用它。

=========
But Firefox and IE can only get: 1,2,3,4
Safari can only get:2,3,4

4.boldness error:莫名其妙的错误

If you add both "action=''" and "onsubmit=''" in one form like:

<form name="user" method="post" onsubmit="add_remember_date()" action='<?=site_url('/admin/action');?>'>

u can get some boresome error.
Suggest:u can cancel action like:

<form name="user" method="post"  onsubmit="add_remember_date()">

I am sure that there is no question.

5.About documet.user.submit();

If u have such sentence below in your code and want to use documet.user.submit():

<input type=”button” id=”submit”>

some error will happen ,so u can change id=’submit’ to id = ’submit_’

“submit” as the id name can take this error,so u should change to another name


10 Responses to “Ajax learning”

  1. John Gent says:

    nice blog (: you should follow me on twitter @gr8p <33

  2. great post thanks for the info (:

  3. awesome site man thanks for the info

  4. thanks so much for this post

  5. Zaposlitev says:

    lbefrgaroskkqvsgbfl, mattress toppers, OmIXQZik.

  6. Samantha says:

    Very educating post, saved your site with hopes to see more information!

  7. In exploring for internet sites connected to search engines web hosting and particularly comparison web hosting Linux plan net, your internet site arrived up.

  8. Thank you very much for posting this great info! I am looking forward to reading more blogs!

  9. Great write up, saved your website in hopes to see more!

Leave a Reply