ʹÓÃjQueryʵÏÖAjaxÒì²½Ìá½»±íµ¥ÊµÏÖ¾Ö²¿Ë¢ÐÂ
jQueryѧϰ±Ê¼Ç
Ìá½»form±íµ¥Ö®ºó£¬²»»áË¢ÐÂÒ³Ã棬¶øÊǾֲ¿Ë¢Ð£¬ÓûÌá½»µÄformÖ»ÒªÓÐid¼´¿É
Èç¹ûʹÓÃgetÇëÇó£¬×¢ÒâÖÐÎÄÂÒÂëÎÊÌ⣬jquery»áÏÈʹÓÃiso8859-1½âÂ룬Ȼºó·¢¸ø·þÎñÆ÷£¬Èç¹ûʹÓÃpostÇëÇó£¬ÔòÖ±½Ó½«ÖÐÎÄÄÚÈÝÌá½»¸ø·þÎñÆ÷½âÎö¡£
ʹÓÃjquery-1.4.2.jsºÍjquery.form.js²å¼þ¡£
Èç¹û´´½¨ÐµÄjsÎļþÖУ¬ÐèÒª¼ÓÉÏ
document.write("<script type='text/javascript' src='jquery-1.4.2.js'></script>")
document.write("<script type='text/javascript' src='jquery.form.js'></script>")
// ¶¯Ì¬¼ÓÔØÒ³Ãæ
// id ÏÔʾҳÃæµÄÈÝÆ÷×é¼þID2
// url Óû¼ÓÔØÒ³ÃæÍøÖ·
// gop getÇëÇó»¹ÊÇpostÇëÇó£¬Ä¬ÈÏget
function loadPage(id, url, gop) {
$("#" + id).addClass("loader");
$("#" + id).append("Loading......");
var type = (gop == "post" ? "post" : "get");
$.ajax( {
type : type,
url : url,
cache : false,
error : function() {
alert('¼ÓÔØÒ³Ãæ' + url + 'ʱ³ö´í£¡')
},
success : function(content) {
$("#" + id).empty().append(content);
$("#" + id).removeClass("loader");
}
});
}
// ¾Ö²¿Ìá½»±íµ¥
function formSubmit(formId, divId, url) {
$('#' + formId).submit(function() {
$(this).ajaxSubmit( {
target : '#' + divId,
url : url,
error : function() {
alert('¼ÓÔØÒ³Ãæ' + url + 'ʱ³ö´í£¡')
}
});
return false;
});
}
Ïà¹ØÎĵµ£º
AjaxÖеķµ»Ø״̬readyStateºÍstatus,ÔÀ´Ã»ÓÐÖØÊÓ¹ýÕâÁ½ÕߵĹØϵ£¬½á¹û½ñÌìд´úÂëʱ³ö²î´íÁË¡£ÎÒµÄÔ´úÂëΪ£º
function requestSome()
{
url=......
xmlHttpRequest.open....
xmlHttpRequest.onreadystatechange = function responseSome();
xmlHttpRequest.send....
}
function resp ......
$.ajax({
type: "POST", //·ÃÎÊWebServiceʹÓÃPost·½Ê½ÇëÇó
......
1£¬±¾Àý×ÓʵÏÖÒ»¸öAjax¸ü¸ÄÊý¾ÝµÄÀý×Ó
Èçͼ£º
1£¬Ð½¨xmlÎļþ£»ÆäÄÚÈÝÈçÏ£º
<?xml version="1.0" encoding="utf-8"?>
<userinfo>
<user>
<id>I</id>
<name>wtq</name>
<password>123456</password>
<phone>0595-8553 ......
APS.NETÒ¹»°µÄÀý×Ó¼ÓÔغ󱨴íÈçÏ£º
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35´íÎó
ÔÒòÊÇδÄܼÓÔØÎļþ»ò³ÌÐò¼¯ system.web.extensions
½â¾ö°ì·¨:
1,Èç¹ûÄãµÄ³ÌÐòÔËÐÐÔÚÄãÄÜ¿ØÖƵķþÎñÆ÷ÉÏ£¬ÄÇô°²×°asp.net ajax¾ÍÐÐÁË£¬ÕâÊÇSystem.Web.ExtensionsµÈdll×öΪGAC² ......
web2.0ºá¿Õ³öÊÀ£¬ajaxÊ×µ±Æä³å£¬½ñÌì×öwebµÄÈç¹ûÔÙ²»Ñ§µãajaxµÄ»°£¬¾ÍÏÔµÄÂäÎéÁË£¬¶øѧajaxµÄÓõĻ·¾³Èç¹ûÊÇasp.net£¬ÄÇajax.netÄã¾Í²»µÃ²»Ñ§ÁË¡£Ê×ÏȾÍÊÇ»·¾³µÄÅäÖã¬ÈçÏÂ
vs2005+sql2005+Winxp sp2+ie6.0+Office2003»·¾³ÉèÖÃÈçÏ£º
ÏÂÔØÍê ASPAJAXExtSetup.msi °²×°¸üкóÔÚÄãµÄϵͳÅÌϵģ¨ÒÔCÅÌΪÀý£© ³öÏÖÕâ¸ö Îļ ......