Ïê½âAJAXºËÐÄÖеÄXMLHttpRequest¶ÔÏó
XMLHttpRequest ¶ÔÏóÊÇAJAX¹¦ÄܵĺËÐÄ£¬Òª¿ª·¢AJAX³ÌÐò±ØÐë´ÓÁ˽âXMLHttpRequest ¶ÔÏó¿ªÊ¼¡£
Á˽âXMLHttpRequest ¶ÔÏó¾ÍÏÈ´Ó´´½¨XMLHttpRequest ¶ÔÏó¿ªÊ¼£¬ÔÚ²»Í¬µÄä¯ÀÀÆ÷Öд´½¨XMLHttpRequest ¶ÔÏóʹÓò»Í¬µÄ·½·¨£º
ÏÈ¿´¿´IE´´½¨XMLHttpRequest ¶ÔÏóµÄ·½·¨£¨·½·¨1£©£º
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
//ʹÓýÏа汾µÄ IE ´´½¨ IE ¼æÈݵĶÔÏó£¨Msxml2.XMLHTTP£©
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
//ʹÓýÏÀÏ°æ±¾µÄ IE ´´½¨ IE ¼æÈݵĶԣ¨Microsoft.XMLHTTP£©
¶ø Mozilla¡¢Opera¡¢Safari ºÍ´ó²¿·Ö·ÇIEµÄä¯ÀÀÆ÷¶¼Ê¹ÓÃÏÂÃæÕâÖÖ·½·¨£¨·½·¨2£©´´½¨XMLHttpRequest ¶ÔÏó£º
var xmlhttp = new XMLHttpRequest();
ʵ¼ÊÉÏInternet Explorer ʹÓÃÁËÒ»¸öÃûΪ XMLHttp µÄ¶ÔÏ󣬶ø²»ÊÇ XMLHttpRequest ¶ÔÏ󣬶ø Mozilla¡¢Opera¡¢Safari ºÍ ´ó²¿·Ö·Ç Microsoft ä¯ÀÀÆ÷¶¼Ê¹ÓõÄÊǺóÕߣ¨ÏÂÎÄͳ³Æ XMLHttpRequest ¶ÔÏ󣩡£IE7¿ªÊ¼Ò²¿ªÊ¼Ê¹ÓÃXMLHttpRequest ¶ÔÏóÁË¡£
ÔÚ´´½¨ XMLHttpRequest ¶ÔÏóµÄʱºòÈç¹û²»Í¬µÄä¯ÀÀÆ÷ʹÓÃÁ˲»ÕýÈ·µÄ·½·¨ä¯ÀÀÆ÷¶¼½«»á±¨´í£¬²¢ÇÒÎÞ·¨Ê¹ÓøöÔÏó¡£ËùÒÔÎÒÃÇÐèÒªÒ»ÖÖ¿ÉÒÔ¼æÈݲ»Í¬ä¯ÀÀÆ÷µÄ´´½¨XMLHttpRequest ¶ÔÏóµÄ·½·¨£º
´´½¨¼æÈݶàä¯ÀÀÆ÷µÄ XMLHttpRequest ¶ÔÏó·½·¨
var xmlhttp = false; //´´½¨Ò»¸öбäÁ¿ request ²¢¸³Öµ false¡£Ê¹Óà false ×÷ΪÅжÏÌõ¼þ£¬Ëü±íʾ»¹Ã»Óд´½¨ XMLHttpRequest ¶ÔÏó¡£
function CreateXMLHttp(){
try{
xmlhttp = new XMLHttpRequest(); //³¢ÊÔ´´½¨ XMLHttpRequest ¶ÔÏ󣬳ý IE ÍâµÄä¯ÀÀÆ÷¶¼Ö§³ÖÕâ¸ö·½·¨¡£
}
catch (e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); //ʹÓýÏа汾µÄ IE ´´½¨ IE ¼æÈݵĶÔÏó£¨Msxml2.XMLHTTP£©
}
catch (e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //ʹÓýÏÀÏ°æ±¾µÄ IE ´´½¨ IE ¼æÈݵĶÔÏó£¨Microsoft.XMLHTTP£©¡£
}
catch (failed){
xmlhttp = false; //Èç¹ûʧ°ÜÔò±£Ö¤ request µÄÖµÈÔȻΪ false¡£
}
}
}
return xmlhttp;
}
ÅжÏÊÇ·ñ´´½¨³É¹¦¾ÍºÜ¼òµ¥ÁË
if (!xmlhttp){
//´´½¨XMLHttpRequest ¶ÔÏóʧ°Ü!
}
else{
//´´½¨³É¹¦!
}
´´½¨ºÃÁËXMLHttpRequest ¶ÔÏóÎÒÃ
Ïà¹ØÎĵµ£º
½áÂÛ£º
jquery 1.3.2 ajax¶Ô±àÂëÎÊÌâ½øÐйý²¿·Ö(¼ûºóÃæ²¹³ä1 )´¦Àí£¬½â¾ö·½°¸ÒÔjspΪÀý×Ó£º
ajaxÌá½»Êý¾Ý¸øjsp£ºajaxËùÔÚÒ³ÃæÎÞÈκÎÒªÇó£¬jspÒ³ÃæÐè×÷Á½·½Ãæ´¦Àí¡£
1.<%@page contentType="application/json" pageEncoding="UTF-8"%>»ò<%@page contentType="application/json" pageEncoding ......
<html>
<head>
<title>jQuery Ajax ʵÀýÑÝʾ</title>
</head>
<script language="javascript" src="../lib/jquery.js"></script>
<script language="javascript">
$(document).ready(function ()
{
$('#send_ajax').click(function (){
&nb ......
ÕâÀïҪ˵µÄûÓдóµÀÀí£¬Ã»ÓÐÔÀí£¬Ã»ÓиßÉîµÄ¼¼Êõ£¬Ã»ÓÐYY£¬Ö»ÊÇ×Ô¼ºµÄÒ»´Î¾Àú£¬ÈռǶøÒÑ¡£ÒÔ·ÀÒÔºóÍü¼ÇÁË£¬ÏÖÔÚдÏÂÀ´¿ÉÒÔ×÷Ϊ²Î¿¼¡£
ʱ¼ä£º5ÔÂÑ×ÈȵÄÒ»Ìì
µØµã£º3Â¥
ÈËÎÎÒ£¬µçÄÔ
½á¹û£ºÄ£ÄâÒ»¸öÍøÕ¾µÄ¾Ö²¿Ë¢Ð¹¦ÄÜ
ÉùÃ÷£ºÐÂÊÖ£¬¶ÔAjaxµÚÒ»´ÎÊ¹Ó ......
ºìÉ«×ÖÌåΪÖ÷Òª´úÂë
jspÒ³ÃæÖÐ
<script language="javascript">
function updateDB(operate){
var objDom=new ActiveXObject("msxml.DomDocument");
var objRoot=objDom.createElement("All");
objDom.appendChild(objRoot);
var k=document.ge ......