ajaxѧϰ±Ê¼Ç1
<html>
<head>
<title></title>
</head>
<mce:script type="text/javascript"><!--
var xmlHttp = false;
try{
xmlHttp = new XMLHttpRequest();
}catch(trymicrosoft){
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(othermicrosoft){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(failed){
xmlHttp = false;
}
}
}
if(xmlHttp == false){
alert("Error initializing XMLHttpRequest!");
}
// --></mce:script>
<mce:script type="text/javascript"><!--
function callServer(){
var city = document.getElementById("city");
if(city==null||city=="") return;
var url = "do_ajax.jsp?city="+escape(city);
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange = updatePage;//onreadyStateChangeʼþÊÇÔÚreadyStateÊôÐÔ·¢Éú¸Ä±äʱ´¥·¢µÄ
xmlHttp.send(null);
}
function updatePage(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
var response = xmlHttp.responseText;
document.getElementById("zipCode").value=response;
}else if(xmlHttp.status == 404){
alert("not exsist");
}else {
alert("Error: status code is " + xmlHttp.status);
}
}
}
// --></mce:script>
<body>
<form action="">
city:<input type="text" id="city" onchange="callServer();">
<br>
zipCode:<input type="text" id="zipCode">
</form>
</body>
</html>
×ÊÁÏÀ´Ô´£ºhttp://www.ibm.com/developerworks/cn/ajax/newto.html?S_TACT=105AGX52&S_CMP=content
Ïà¹ØÎĵµ£º
µ±ÓÃajax·µ»Ø¶à¸öÖµµÄʱºò£¬¿ÉÒÔÓÃxml£¬Ò²¿ÉÒÔÓÃjson
jsonʵÀý
<html>
<head>
<title>AjaxTest</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
& ......
ǰ¼¸ÌìÔÚFirebugÀ©Õ¹¿ª·¢Ò»ÎÄÖоÍÌáµ½¹ýFirephpÕâ¸ö»ùÓÚFirebugµÄ²å¼þ£¬Í¨¹ýʹÓÃFirephpÄã¿ÉÒÔÔÚFirebugµÄConsoleÀ¸Öп´µ½Òªµ÷ÊÔµÄÊý¾Ý£¬¶ø²»Ó°Ïìphp³ÌÐòµÄÕý³£Ö´ÐУ¬ËùÒÔ˵£¬Õâ¶«Î÷¶ÔÓÚAjax¿ª·¢ÊǺÜÓаïÖúµÄ£¡ÏÂÃæÒ»ÆðÀ´¿´ÏÂFirephpµÄʹÓ÷½·¨¡£
µÚÒ»²½£º°²×°
1.Èç¹ûÄãµÄFireFoxûÓÐFirebugÕâ¸ö²å¼þµÄ»°£¬Ê×ÏÈÒª°²×°Fire ......
ÎÊÌâ
ÔÚÏÖÓÐÖ÷Õ¾ÖÐʹÓõÄÊÇÊÇGBK±àÂëµÄ£¬µ±±íµ¥Ê¹ÓÃform submit·½Ê½µÝ½»µÄ»°Ã»ÓÐÎÊÌ⣬·þÎñÆ÷¶ËÄܹ»Õýȷʶ±ð×Ö·û±àÂë¡£µ«ÊÇ£¬µ±¿Í»§¶ËʹÓÃajaxµÄ·½Ê½µÝ½»±íµ¥µÄ»°£¬·þÎñÆ÷¶Ëʶ±ð¿Í»§¶ËµÝ½»µÄ±íµ¥µÄÄÚÈÝ£¬µ±ÄÚÈÝÖÐÓÐÖÐÎÄ×Ö·ûµÄ»°¾Í»á³öÏÖÂÒÂëÏÖÏó¡£
ÔÒò·ÖÎö
¾¿ÆäÔÒò£¬ÆäʵºÜ¼òµ¥£¬Ê¹ÓÃajax·½Ê½Ìá½»µÄ±íµ¥ÊÇÓÃutf-8± ......
http://www.ajaxlines.com/ajax/stuff/article/using_google_is_ajax_search_api_with_java.php
I was rather depressed over a year ago when Google deprecated their SOAP Search API with their AJAX Search API. Essentially Google was saying that they didn want anyone programmatically accessing Google search ......