AJAXµÄreadyStateµÄÎåÖÖ״̬Ïê½â
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLhTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function startRequest(){
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open("GET","simpleResponse.xml");
xmlHttp.send();
}
function handleStateChange(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200||xmlHttp.status==0){
alert("The server replied with: "+xmlHttp.responseText);
}
}
}
</script>
¸Õ¿ªÊ¼ÔËÐеÄʱºò£¬ÔõôҲִÐв»Á˽á¹û£¬ºóÀ´ÓûðºüµÄfirebug·¢ÏÖÎÒµÄxmlHttp.readyStateµÄÖµÒ»Ö±ÊÇ0£¬ºÜÆæ¹Ö£¬ºóÀ´¾ÍÈ¥ÕÒreadyState£¬·¢ÏÖ readyStateÔÀ´ÓÐÎåÖÖ״̬£º
0 £ £¨Î´³õʼ»¯£©
´Ë½×¶ÎÈ·ÈÏXMLHttpRequest¶ÔÏóÊÇ·ñ´´½¨£¬²¢Îªµ÷ÓÃopen()·½·¨½øÐÐδ³õʼ»¯×÷ºÃ×¼±¸¡£ÖµÎª0±íʾ¶ÔÏóÒѾ´æÔÚ£¬·ñÔòä¯ÀÀÆ÷»á±¨´í££¶ÔÏó²»´æÔÚ¡£
1 £ £¨ÔØÈ룩
´Ë½×¶Î¶ÔXMLHttpRequest¶ÔÏó½øÐгõʼ»¯£¬¼´µ÷ÓÃopen()·½·¨£¬¸ù¾Ý²ÎÊý(method,url,true)Íê³É¶ÔÏó״̬µÄÉèÖᣲ¢µ÷ÓÃsend()·½·¨¿ªÊ¼Ïò·þÎñ¶Ë·¢ËÍÇëÇó¡£ÖµÎª1±íʾÕýÔÚÏò·þÎñ¶Ë·¢ËÍÇëÇó¡£
2 £ £¨ÔØÈëÍê³É£©
´Ë½×¶Î½ÓÊÕ·þÎñÆ÷¶ËµÄÏìÓ¦Êý¾Ý¡£µ«»ñµÃµÄ»¹Ö»ÊÇ·þÎñ¶ËÏìÓ¦µÄÔʼÊý¾Ý£¬²¢²»ÄÜÖ±½ÓÔÚ¿Í»§¶ËʹÓá£ÖµÎª2±íʾÒѾ½ÓÊÕÍêÈ«²¿ÏìÓ¦Êý¾Ý¡£²¢ÎªÏÂÒ»½×¶Î¶ÔÊý¾Ý½âÎö×÷ºÃ×¼±¸¡£
3 £ £¨½»»¥£©
´Ë½×¶Î½âÎö½ÓÊÕµ½µÄ·þÎñÆ÷¶ËÏìÓ¦Êý¾Ý¡£¼´¸ù¾Ý·þÎñÆ÷¶ËÏìӦͷ²¿·µ»ØµÄMIMEÀàÐÍ°ÑÊý¾Ýת»»³ÉÄÜͨ¹ýresponseBody¡¢responseText»òresponseXMLÊôÐÔ´æÈ¡µÄ¸ñʽ£¬ÎªÔÚ¿Í»§¶Ëµ÷ÓÃ×÷ºÃ×¼±¸¡£×´Ì¬3±íʾÕýÔÚ½âÎöÊý¾Ý¡£
4 £ £¨Íê³É£©
´Ë½×¶ÎÈ·ÈÏÈ«²¿Êý¾Ý¶¼ÒѾ½âÎöΪ¿Í»§¶Ë¿ÉÓõĸñʽ£¬½âÎöÒѾÍê³É¡£ÖµÎª4±íʾÊý¾Ý½âÎöÍê±Ï£¬¿ÉÒÔͨ¹ýXMLHttpRequest¶ÔÏóµÄÏàÓ¦ÊôÐÔÈ¡
Ïà¹ØÎĵµ£º
Ê×ÏÈ°Ñ´úÂë¸ø´ó¼Ò£¬ÏÂÃæÊǽâÊÍ
/**
* »ñµÃXMLHttpRequest¶ÔÏó
*/
function createXHR(){
var x=[function(){return new ActiveXObject("Msxm12.XMLHTTP");},function(){return xmhttp=new ActiveXObject("Microsoft.XMLHTTP");},
&nb ......
<html>
<body>
<script¡¡language="JavaScript">
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡req¡¡=¡¡null;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡function¡¡test()¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡var¡¡province¡¡=¡¡document.all("province").value;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡req¡¡=¡¡new¡¡ActiveXObject("Microsoft.XMLHTTP ......
asp.net ajaxÖÐÎÄÂÒÂëµÄ½â¾ö£¿
2010-01-19 12:06
ÒÔǰûÔõô×ÐϸµÄÑо¿¹ýajax,Ö»ÊÇÓõ½Á˾ÍÖ±½ÓÄùýÀ´ÓÃ,·¢ÏÖÁËÎÊÌâÔÙÕÒ½â¾ö·½·¨.ÒÔÏÂÊÇÎÒÔÚÕÒ½â¾öÎÊÌâµÄ¹ý³ÌÖеÄÒ»µãССµÄ×ܽá.
Ò».̸AjaxµÄGetºÍPostµÄÇø±ð
Get·½Ê½:
ÓÃget·½Ê½¿É´«Ëͼòµ¥Êý¾Ý£¬µ«´óСһ°ãÏÞÖÆÔÚ1KBÏ£¬Êý¾Ý×·¼Óµ½urlÖз¢Ë ......
1) TextboxList×Ô¶¯Íê³É £¨Ô´Â룬ÑÝʾ£©
Õâ¸ö¿Ø¼þÖ÷ÒªÀ´×ÔFacebook°É£¬ÔÚÍøÒ×µÄÓʼþÀïÒ²ÄÜ¿´µ½£¬»¹ÓÐhotmailµÈµÈ£¬ÔÚÎı¾¿òÀïÊäÈëÎı¾²»µ«¿ÉÒÔ³öÏÖÏà¹ØÊý¾ÝµÄÁÐ±í£¬¶øÇÒÑ¡ÖкóµÄ×Ö·û´®»¹»á±ä³ÉÒ»¸öСͼ±ê¡£Õâ¸ö¿Ø¼þÖ÷ÒªÓÃÔÚµç×ÓÓʼþÖаɡ£
2) Ajax IM¼´Ê±ÁÄÌì £¨Ô´Â룬ÑÝʾ£©
Ajax IMÊÇÒ»¸öºÜÅ£µÄ¼´Ê±ÁÄÌìµÄ¿Í»§¶Ë£¬Äã ......