jQuery Ajax ʵÀýÑÝʾ
<
script language=
"javascript"
>
$(
document)
.ready
(
function
(
)
{
$(
'#send_ajax'
)
.click
(
function
(
)
{
var
params=
$(
'input'
)
.serialize
(
)
;
//ÐòÁл¯±íµ¥µÄÖµ
$.ajax
(
{
url:
'ajax_json.php'
,
//ºǫ́´¦Àí³ÌÐò
type:
'post'
,
//Êý¾Ý·¢ËÍ·½Ê½
dataType:
'json'
,
//½ÓÊÜÊý¾Ý¸ñʽ
data:
params,
//Òª´«µÝµÄÊý¾Ý
success:
update_page //»Ø´«º¯Êý(ÕâÀïÊǺ¯ÊýÃû)
}
)
;
}
)
;
//$.post()·½Ê½£º
$(
'#test_post'
)
.click
(
function
(
)
{
$.post
(
'ajax_json.php'
,
{
username:
$(
'#input1'
)
.val
(
)
,
age:
$(
'#input2'
)
.val
(
)
,
sex:
$(
'#input3'
)
.val
(
)
,
job:
$(
'#input4'
)
.val
(
)
}
,
function
(
data)
//»Ø´«º¯Êý
{
var
myjson=
''
;
eval
(
'myjson='
+
data +
';'
)
;
$(
'#result'
)
.html
(
"ÐÕÃû:"
+
myjson.username
+
"<br/>¹¤×÷:"
+
myjson[
'job'
]
)
;
}
)
;
}
)
;
//$.get()·½Ê½£º
$(
'#test_get'
)
.click
(
function
(
)
{
$.get
(
'ajax_json.php'
,
{
username:
$(
"#input1"
)
.val
(
)
,
age:
$(
"#input2"
)
.val
(
)
,
sex:
$(
"#input3"
)
.val
(
)
,
job:
$(
"#input4"
)
.val
(
)
}
,
function
(
data)
//»Ø´«º¯Êý
{
var
myjson=
''
;
eval
(
"myjson="
+
data +
";"
)
;
$(
"#result"
)
.html
(
myjson.job
)
;
}
)
;
}
)
;
}
)
;
function
update_page (
json)
//»Ø´«º¯ÊýʵÌ壬²ÎÊýΪXMLhttpRequest.responseText
{
var
str=
"ÐÕÃû:"
+
json.username
+
"<br />"
;
str+=
"ÄêÁä:"
+
jso
Ïà¹ØÎĵµ£º
Dojo1.3.x
µÄ
Ajax
ʾÀý
ÕûÀíÈË£º»Æ³Ï
QQ
Ⱥ£º
65643887
ÕâÆªÎÄÕÂÖ÷ÒªÊǰïÖú¶Ô
Dojo
¸ÐÐËȤµÄÅóÓÑÃÇ¿ì
ËÙʵÏÖÍøÕ¾ÉϵÄÀý×Ó¡£
http://sitepen.com/labs/guides/?guide=DojoQuickStart#Ajax
Ëü½Ì³Ì·ÖÁË
3
²¿·Ö£¬ÆäÖеÄÀý×Ó²»ÈÝÒ×
ÉÏÊÖ¡£ÎÒÕâÀïÌṩһ¸ö´ò°üÎļþ
AjaxWithDojo.war
ÏÂÃæÎÒ½«Ïêϸ˵Ã÷²Ù×÷²½Ö ......
ÏÖÔÚ¸Õ¸Õ¿´Ò»Ð©¹ØÓÚAjaxµÄһЩ֪ʶµã¡£°ÑËüдÏÂÀ´£¬×÷Ϊ֪ʶµÄ±¸Íü¼£¡
ÒÔÏ´¿Êô¸öÈËÀí½â£¡£¡£¡
1. Ajax·ÖÎªÒ³Ãæ²¿·Ö£¨Ç°¶Ë£©£¬ºÍºǫ́´¦Àí²¿·Ö£¨ºó¶Ë£¬servlet£©£»
2. Ò³Ãæ£º´´½¨XmlHttpRequest¶ÔÏ󣬲»Í¬µÄä¯ÀÀÆ÷£¬ËùÖ§³ÖµÄXmlHttpRequest¶ÔÏó²»Í¨£»
Ò³Ãæ£º½¨Á¢·¢ ......
-------------------------jspÖеÄjs´úÂë--------------------
<script type="text/javascript">
function ajaxFunction(sort){
var xmlHttp;
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new X ......
ÒÔÎÒÒÔǰдµÄÒ»¸öÁ·Ï°AJAXµÄ»áÔ±×¢²áÒ³ÃæÎªÀý¡£
ÏÂÃæÕâЩÖ÷ÒªÊÇÔÚÊäÈëÓû§Ãû£¬¹â±êÀ뿪ÊäÈë¿ò¾Í½øÐÐÅжϸÃÓû§ÃûÊÇ·ñºÏ·¨µÄajax·½·¨¡£
£¨1£©Xmlhttprequest AJAXÖ®ºËÐÄ
function S_Xmlhttprequest(){
if(window.ActiveXObject) //IE
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
else if(window.XmlHTTPRe ......