Ajax¿çÓòÇëÇóÌáʾ¾Ü¾ø·ÃÎÊ£¿£¿£¿ - Web ¿ª·¢ / Ajax
C# code:
<script type="text/javascript">
var xmlHttp;
function showJ()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return
}
var url="http://www.ueepay.com/testConnect.ashx"
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.status==200)
{
var data=xmlHttp.responseText;
alert(data);
if(data=="OK")
{
alert("dnal");
}
}
}
function GetXmlHttpObject()
{
var xmlhttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlhttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlhttp;
}
</script>
Â¥ÉÏÊÇΪºÃÈË
Ïà¹ØÎÊ´ð£º
°´Å¥·ÅÔÚUpdatePanel1£¬Ïëͨ¹ýµã»÷µ÷ÓÃDictionaryTvAdd.aspxµ¯³öÒ»¸ö×Ó´°Ìå
ÓÃÏÂÃæµÄÓï¾äÌáʾÎÒȱÉÙ¶ÔÏó
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.R ......
ÎÒÏÖÔÚÓÃstruts2¿ò¼Ü,ÐèҪʹÓÃajaxʵÏÖ¾Ö²¿Ë¢Ð£¬µ«ÊÇ´ÓÈÝÆ÷Àï·µ»ØµÄÖµ²»ÖªµÀÔõô´Óstruts.xmlÅäÖÃÎļþÀïÓ³Éäµ½jspÒ³ÃæÀÒÔÇ°servletÀïдout.orint("xxxxx")¾Í¿ÉÒԵõ½~£¬µ«ÊÇÏÖÔÚÓÃstruts¾Í²»ÖªµÀÔõôР......
function callback(){
if (req.readyState == 4){
if(req.status == 200){
var msg = req.responseXML.getElementsByTagName("msg")[0];
// alert(msg.chil ......
´úÂëÈçÏ Çë¸ßÊÖ Ö¸µãÏ лл
ajax_http.js
-------------
function getXMLHTTP() {
var xmlhttp;
if (window.ActiveXObject) {
//IE
try {
......
ÎÊÌâ: ÏÖÔÚÌá½»Ö®ºó¾Í²»ÄÜÌøµ½ajax.jsÖÐÖ¸¶¨µÄservlet
¶øÊÇÓÖÖØнøÈëµ½ÁËpub_hotel_t.jspÒ³Ãæ. Ò²¾ÍÊÇûÓÐÖ´Ðе½ajaxÀïÃæÈ¥ ´ó¼Ò°ïæ¿´¿´ÊÇʲôÔÒò°É.
ÊDz»ÊǺÍÌá½»µÄ°´Å¦ÓйØÄ ......