ajax GET·½Ê½Ìá½»£¬ÖÐÎIJÎÊýÂÒÂëµÄÎÊÌâ
ÔÚ¹¹ÔìurlÊÇÓÃjavascript×Ô´øµÄencodeURIComponent·½·¨½«²ÎÊý½øÐбàÂ룬ÏÂÃæÊÇÎҵĴúÂë
var url = "handel.jsp?name="+encodeURIComponent(document.form1.name.value);
httpRequest = createHttpRequest();
httpRequest.onreadystatechange = aa;
httpRequest.open("GET",url,true);
httpRequest.send(null);
ºǫֱ́½Ó½ÓÊܾͿÉÒԵõ½ÖÐÎÄ£¬²»ÐèҪתÂë
String nameFalse = this.getRequest().getParameter("name")¡£
Ïà¹ØÎĵµ£º
<script type="text/javascript">
function addUrl(){
//1¡¢ÉèÖÃÇëÇóurlµØÖ·
var name = document.getElementById("name").value;
var text = document.getElementById("url").value;
var url = "insertUrl.do?name="+name+
"&url="+text+"&time"+new Date() ;
//2¡¢´´½¨xmlHttpRequest¶ÔÏó
x ......
¿Í»§¶Ë´úÂ룺
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function sl(url){
......
ÔÚ.netµÄÑéÖ¤¿Ø¼þÖÐÓÐÒ»¸öCustomValidatorÑéÖ¤¿Ø¼þ£¬ÆäÊôÐÔClientValidationFunctionΪ¿Í»§¶Ëº¯Êý£¬ÔÚÐèÒªÑéÖ¤µÄ¿Ø¼þʧȥ½¹µã»òÕßpostÊý¾Ýʱ£¬µ÷Óøú¯Êý¡£
ǰ̨£º
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomValidatorTest.aspx.cs" Inherits="Web.CustomValidatorTest" %>
<!DO ......
function CreateXmlHttp()
{
if(window.ActiveXObject)
{
try
{
XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){};
try
{
XmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){};
}
else if(window.XMLHt ......
jsûЧ¹û:Èç¹ûÔÚÒÔUpdatePanelµÄ·½Ê½µÄ¾Ö²¿»Ø´«ÖУ¬ÆÕͨµÄJavascript´úÂëÔÚÕâÖÖ¾Ö²¿»Ø´«ÖоͲ»»áÔÚ´¥·¢ÁË£¬¾Í±ØÐëʹÓÃscriptmanager.RegisterClientScript·½·¨£¨ÔÚ<form>ºóÃæ×¢²á<script>£©ºÍscriptmanager.RegisterStartupScript·½·¨£¨ÔÚ</form֮ǰע²á<script>£©
ÔÚÄãµÄÓû§¿Ø¼þµÄºó¶ËµÄij¸öºÏÊÊÎ ......