jQuery Ajax Ôõô»ñÈ¡ÁíÒ»Ò³ Response.WriteÊý¾Ý£¿
C# code:
<script type="text/javascript">
function get(aid){
$.ajax({
url:"t2.aspx?id="+aid+" & time="+new Date().toString(),
type:'GET',
success:function(){
$('#new').html(arguments[0]);////???ÕâÀïÔõô½ÓÊÕ£¬²»ÖªµÀÎÒд´íûÓУ¿
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="new" id="new"> </div>
<script language="javascript" type="text/javascript">
getDigg(197);
</script>
C# code:
protected void Page_Load(object sender, EventArgs e)
{
string s = Session["aid"].ToString();
int aid = int.Parse(s);
if (aid == 197)
{
Response.Write("<div class=\"act\">ok</div>");
}
Response.End();
}
ÊǶԣ¬jqĬÈϽûÓûº´æ£¬Òò´Ë²»ÓÃÄãÀ´¼Óʱ¼ä
²»ÊÇÓÃSession»ñÈ¡°É url´«ÖµÅ¶
1 º¯ÊýÃû³ÆÊÇgetDigg²»ÊÇget°É, ÆäËû²âÊÔÏÂÀ´¿ÉÒÔµÄ
2 ·þÎñÆ÷¶Ë´úÂëÀï ΪºÎÈ¡Session? Ó¦¸ÃÊÇRequest°É
HT
Ïà¹ØÎÊ´ð£º
ÎÒÔÚÒ»¸öhtmlÖÐдÈçÏ´úÂ룺
JScript code:
<html>
<head>
<script type="text/javascript" charset="utf-8"
src="script/jquery-1.3.2.min ......
ÎÒÓÃjqueryÎÞË¢ÐÂÉÏ´«Í¼Æ¬ºó·µ»Øjson¸ñʽµÄÊý¾Ý±¨´í
£¨Êµ¼ÊÉÏͼƬÊÇÉÏ´«³É¹¦µÄÁË£¬Ö»ÊÇ·µ»Øjson¸ñʽ×ܶÁ²»µ½£¬×ÜÊDZ¨´í£©
ÎÒµ÷ÊÔÉÏ´«µÄashxÒ³ÈçÏÂ
ÎÞ·¨ÏÔʾ XML Ò³¡£
ʹÓà Ñùʽ±íÎÞ·¨²é¿´ XML ÊäÈë¡£Çë¸ü ......
ÎÊÌâ: ÏÖÔÚÌá½»Ö®ºó¾Í²»ÄÜÌøµ½ajax.jsÖÐÖ¸¶¨µÄservlet
¶øÊÇÓÖÖØнøÈëµ½ÁËpub_hotel_t.jspÒ³Ãæ. Ò²¾ÍÊÇûÓÐÖ´Ðе½ajaxÀïÃæÈ¥ ´ó¼Ò°ïæ¿´¿´ÊÇʲôÔÒò°É.
ÊDz»ÊǺÍÌá½»µÄ°´Å¦ÓйØÄ ......
ÔÚservletÖУ¬ÓÐÖÐÎÄ´«µÝµ½Ò³ÃæÖеÄjsÀïÃ棬ÔÚjsÏÔʾÖÐÎÄʱ£¬³öÏÖÂÒÂë¡£
serletÀïÃ沿·Ö´úÂ룺
Java code:
StringBuffer sb=new StringBuffer("<nprovince>");
for(City city:clist){
......
ÔÚservletÖУ¬ÓÐÖÐÎÄ´«µÝµ½Ò³ÃæÖеÄjsÀïÃ棬ÔÚjsÏÔʾÖÐÎÄʱ£¬³öÏÖÂÒÂë¡£
serletÀïÃ沿·Ö´úÂ룺
Java code:
StringBuffer sb=new StringBuffer("<nprovince>");
for(City city:clist){
......