AJAX±à³Ìʵ¼ùÖ®Óë·þÎñÆ÷ͨÐÅ_Ajax±à³Ì_ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØ--Powered by WWW.RONGSEN.COM.CN

AJAX±à³Ìʵ¼ùÖ®Óë·þÎñÆ÷ͨÐÅ

×÷ÕߣººÚ¿Í·ÀÏßÍø°²Ajax½Ì³Ì»ùµØ À´Ô´£ººÚ¿Í·ÀÏßÍø°²Ajax½Ì³Ì»ùµØ ä¯ÀÀ´ÎÊý£º0

±¾Æª¹Ø¼ü´Ê£ºÍ¨ÐÅ·þÎñÆ÷ʵ¼ù±à³Ì
ºÚ¿Í·ÀÏßÍø°²ÍøѶ£º¡¡¡¡Ê×ÏÈ¿´Ï¿´ÏÂÏà¶Ô¼òµ¥Ð©µÄ--Ïò·þÎñÆ÷·¢ËÍÒ»¸ö°üº¬ÓÐÃû/Öµ¶ÔµÄ¼òµ¥²éѯ´®£¬ÔÚÕâÖÖÇé¿öÏÂXHP¼´¿ÉÒÔÓÃGETÒ²¿ÉÒÔÓÃPOST¡£GETfunction doRequestUsingGET() {¡¡createXMLHttpRequest();¡¡var...

¡¡¡¡Ê×ÏÈ¿´Ï¿´ÏÂÏà¶Ô¼òµ¥Ð©µÄ--Ïò·þÎñÆ÷·¢ËÍÒ»¸ö°üº¬ÓÐÃû/Öµ¶ÔµÄ¼òµ¥²éѯ´®£¬ÔÚÕâÖÖÇé¿öÏÂXHP¼´¿ÉÒÔÓÃGETÒ²¿ÉÒÔÓÃPOST¡£

GET

function doRequestUsingGET() {
¡¡createXMLHttpRequest();

¡¡var queryString = " GetAndPostExample? " ;
¡¡queryString = queryString + createQueryString()+ " &timeStamp= " + new Date().getTime();
¡¡xmlHttp.onreadystatechange = handleStateChange;
¡¡xmlHttp.open( " GET " , queryString, true );
¡¡xmlHttp.send( null );
}

POST

function doRequestUsingPOST() {
¡¡createXMLHttpRequest();

¡¡var url = " GetAndPostExample?timeStamp= " + new Date().getTime();
¡¡var queryString = createQueryString();

¡¡xmlHttp.open( " POST " , url, true );
¡¡xmlHttp.onreadystatechange = handleStateChange;
¡¡xmlHttp.setRequestHeader( " Content-Type " , " application/x-www-form-urlencoded " );
¡¡xmlHttp.send(queryString);

¡¡¡¡queryString¾ÍÊÇÃû/Öµ¶ÔµÄ²ÎÊýÐÎʽÁË£¨Èçname=LiLin&age=23£©,ÔÚµ÷ÓÃOPEN·½·¨ÖУ¬µ±ÇëÇó·½·¨ÊÇÓÃPOSTµÄʱºòΪÁËÈ·±£·þÎñÆ÷ÖªµÀÇëÇóÌåÖÐÓÐÇëÇó²ÎÊý£¬ÐèÒªµ÷ÓÃsetRequestHeader£¬½«Content-TypeÖµÉèÖÃΪapplication/x-www-form-urlencoded.µ±È»Ò²¿É²»·ÅÔÚÇëÇóÌåÖУ¨ÄǾͲ»ÒªÓÃPOSTÀ²£¡£©

¡¡¡¡´Ëʱserver´¦Àí£º

import java.io. * ;
import java.net. * ;
import javax.servlet. * ;
import javax.servlet.http. * ;

public class GetAndPostExample extends HttpServlet {

¡¡protected void processRequest(HttpServletRequest request, HttpServletResponse response, String method)
throws ServletException, IOException {

¡¡¡¡// Set content type of the response to text/xml
¡¡¡¡response.setContentType( " text/xml " );

¡¡¡¡// Get the user's input
¡¡¡¡String firstName = request.getParameter( " firstName " );
¡¡¡¡String middleName = request.getParameter( " middleName " );
¡¡¡¡String birthday = request.getParameter( " birthday " );

¡¡¡¡// Create the response text
¡¡¡¡String responseText = " Hello " + firstName + " " + middleName
+ " . Your birthday is " + birthday + " . "
+ " [Method: " + method + " ] " ;

¡¡¡¡// Write the response back to the browser
¡¡¡¡PrintWriter out = response.getWriter();
¡¡¡¡out.println(responseText);

    ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤·½°¸±¾ÆªÁ¬½Ó£ºhttp://www.rongsen.com.cn/show-15705-1.html
Íøվά»¤½Ì³Ì¸üÐÂʱ¼ä:2012-04-05 00:05:53  ¡¾´òÓ¡´ËÒ³¡¿  ¡¾¹Ø±Õ¡¿
ÎÒÒªÉêÇë±¾Õ¾£ºNµã | ºÚ¿Í·ÀÏß¹ÙÍø |  
רҵ·þÎñÆ÷ά»¤¼°Íøվά»¤ÊÖ¹¤°²È«´î½¨»·¾³£¬ÍøÕ¾°²È«¼Ó¹Ì·þÎñ¡£ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØÕÐÉ̽øÐÐÖУ¡QQ:29769479

footer  footer  footer  footer