AjaxʾÀý
¿Í»§¶Ë´úÂ룺
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function sl(url){
//¿É¼ÓһЩÑéÖ¤ÐÅÏ¢
document.getElementById('slform').style.display='';//´ò¿ªÊÜÀíform
//alert("url="+url);
createXMLHttpRequest();//Ϊ xmlHttp ¸³Öµ
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = slcallback;
xmlHttp.send(null);
}
function slcallback(){
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var applyPerson = xmlHttp.responseXML.getElementsByTagName('applyPerson')[0].firstChild.data;
var applyIdCard = xmlHttp.responseXML.getElementsByTagName('applyIdCard')[0].firstChild.data;
document.getElementById('slPerson').value=applyPerson;
document.getElementById('slId').value=applyIdCard;
}
}else{
}
}
ÔÚactionÀ·µ»Øµ½Ò»¸öjspÒ³Ãæ£¬ÔÚjspÒ³ÃæÀï°ÑÄÚÈÝÉèΪxml¸ñʽ
ÈçÏ£º
<%@ page contentType="text/xml; charset=GBK"%>
<%
String applyPerson = (String)request.getAttribute("applyPerson");
String applyIdCard = (String)request.getAttribute("applyIdCard");
%>
<?xml version="1.0" encoding="GBK"?>
<response>
<applyPerson><%=applyPerson%></applyPerson>
<applyIdCard><%=applyIdCard%></applyIdCard>
</response>
Ïà¹ØÎĵµ£º
×î½üµÄÏîÄ¿ÀïÓõ½AjaxControlToolkit 3.5,ÏîÄ¿Íê³ÉÒÔºóÔÚ±¾µØ²âÊÔûÎÊÌ⣬·Åµ½·þÎñÆ÷ÉÏÈ¥ÔÚIE6¾Í³öÏÖAjax ¿Í»§¶Ë¿ò¼ÜδÄܼÓÔØµÄÎÊÌ⣬ÔÚFF£¬IE7£¬Opera£¬SafariµÈä¯ÀÀÆ÷¶¼Ã»ÎÊÌâ£¬ÕæÊǸ㲻¶®MSÔõô¸ãµÃ£¬ÏÖÔÚ ¾ÍÏëÅׯúIE6£¬ÕҵĺÃÐÁ¿à°¡£¬ÍøÉÏ˵µÄ½â¾ö·½°¸¶¼ÊÔ¹ýÁË£¬¶¼Ã»Óã¬×îºóÕÒµ½µÄ´ð°¸ÊÇ£ºÓ¦ÓóÌÐòµÄ±àÂëÎÊ Ì⣬ֻҪÔÚ ......
µÚËÄÕ Ajax·þÎñÆ÷À©Õ¹ÆÊÎö
Ajax·þÎñÆ÷À©Õ¹£ºASP.NET Ajax¿ò¼ÜµÄ·þÎñÆ÷¶Ë¡£
4.1ASP.NET ¿ª·¢ÈËÔ±µÄAjax
Ϊ·þÎñÆ÷¶Ë¿ª·¢ÌṩAjaxÖ§³Ö¡£°üÀ¨Ò»×éеķþÎñÆ÷¿Ø¼þºÍ·þÎñ£¬ÓÃÀ´ÃþÄâ¿Í»§¶ËAjaxÐÐΪ¡£
4.2¸Ä½øÔÓÐASP.NETÍøÕ¾
(1)¸ÄÉÆÍøÂçÑÓ³Ù£º¾¡×î´ó¿ÉÄܼõÉÙä¯ÀÀÆ÷ºÍ·þÎñÆ÷Ö®¼ä´«µÝµÄÊý¾ÝÁ¿¡£
(2)Ïû³ýȫҳà ......
index.aspÎļþ ±£´æutf-8
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
<form id="form1" name="form1" method="post">
<input name="ip" type="text" id="ip" style="width:170px" />
</form>
<mce:script type="text/javascript" src="ajaxrequest-m ......
jqueryÖÐÓÃajax(Ã²ËÆ±àÂëĬÈÏΪutf-8)Èç¹ûÓÐÖÐÎĵϰ »á³öÏÖÂÒÂë ÏÂÃæµÄ½â¾ö°ì·¨Ö®Ò»£º
ÒÔÏÂÊÇjsÖеĴúÂë
classname=encodeURI($('#classname').val());
classdescription=encodeURI($('#classdescription').val());
actionArr={classname:classname,classdescription:classdescription};
$.post("product_class ......
//==================>¡¾index.jsp¡¿===============================
<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% String path=request.getContextPath(); %>
<%@page import="com.sinoest.dfrf.orm.pojo.Mainmenu"%>
<%@page import="com.si ......