ajax XMLHttpRequest post get
/*ÔÚÓÐÖÐÎIJÎÊýʱ,½ÓÊÕ·½ÐèҪʹÓÃUTF-8·½Ê½¶ÔÊý¾Ý½øÐнâÂë
*²»Ö§³Öpost¸½¼þ
*/
function getXmlHttpRequest() {
var xmlHttpRequest = null;
try {
xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e1) {
try {
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttpRequest = null;
}
}
if (xmlHttpRequest == null && typeof(XMLHttpRequest) != 'undefined') {
xmlHttpRequest = new XMLHttpRequest();
}
return xmlHttpRequest;
}
/*ʹÓÃpost·½Ê½·¢ËÍÊý¾Ý
*url:submit·¾¶
*arguments:²ÎÊý,Èçname=jese&sex=womanz,ÖÐÎÄÊý¾ÝʱʹÓÃ'name='+getEncodeURIComponent('ÀîËÄ')+'&sex='+getEncodeURIComponent('ÄÐ')½øÐбàÂë
*synchFlag:ͬ²½±ê¼Ç,falseΪͬ²½·½Ê½,trueΪÒì²½·½Ê½
*returnType:·µ»ØÄÚÈÝÀàÐÍ0=responseBody;1=responseStream;2=responseText;3=responseXML
*execute:ΪÒì²½·½Ê½Ìá½»ºóµÄ»Øµ÷º¯Êý,´Ëº¯ÊýÓÃÓÚ´¦Àí·µ»ØÊý¾Ý,¸ñʽΪfunction (obj){},objΪ·µ»ØÄÚÈÝ
*/
function postData(url, arguments, synchFlag, returnType, execute) {
var xmlHttpRequest = getXmlHttpRequest();
if (xmlHttpRequest == null) return false;
xmlHttpRequest.open("POST", url, synchFlag);
xmlHttpRequest.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
xmlHttpRequest.setRequestHeader("Content-Length", arguments.length);
if (synchFlag) {
xmlHttpRequest.onreadystatechange = function() {
&nb
Ïà¹ØÎĵµ£º
<script language="javascript" type="text/javascript">
¡¡¡¡function doubleSalary()
¡¡¡¡{
¡¡¡¡var employee = new Object();
¡¡¡¡employee.FirstName = "X";
¡¡¡¡employee.LastName = "PP";
¡¡¡¡employee.Salary = 1000;
......
<input type="button" onclick="ajaxTest()" value="AJAX²âÊÔ">
<input type="button" onclick=" document.getElementById('weather').innerHTML='' " value="Òþ²Ø">
<mce:script type="text/javascript"><!--
// 1. ³õʼ»¯ ÇëÇó ¶ÔÏó
// Mozilla/Firefox 쵀
//var xmlhttp = ne ......
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² ......
ÔÚʹÓÃjQuery µÄAjax¼ÓÔØÊý¾ÝÊÇ Èç¹ûʹÓÃget·½Ê½´«µÝ²ÎÊýÔò´æÔÚÒ»ÏÂÎÊÌâ
firefoxÏ´«µÝÊý¾ÝÕý³£
ieÏÂÔò»á³öÏÖ»º´æÎÊÌâ
½â¾ö·½·¨£º
1¡¢http://yourwebsite?parseInt(Math.random() * 1000) ÔÚurlºóÃæ¼ÓÉÏÒ»¸öËæ¼´Êý£¬ÕâÑùÿ´Î·¢Ë͵ľͲ»Ò»ÑùÁË£¬¶øÇÒ²»Ó°ÏìÄãµÄ¹¦ÄÜ.
2¡¢Ê¹ÓÃpost´«µÝ²ÎÊý
......
ÈçÉÏͼËùʾΪAccordion¿Ø¼þ£º
¸Ð¾õ²»´íµÄÑùʽ
<style type="text/css">
.headerBg{cursor:hand;text-align:center;width:180px;height:21px;background-image:url(images/ajaxmenubg1.gif);FONT-SIZE: 12px;line-height:21px;} ......