這篇文章主要對jquery ajax 局部無重新整理更新資料的實現案例進行了介紹,需要的朋友可以過來參考下,希望對大家有所協助
要更新的頁面 代碼如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script src="js/jquery.js" type="text/javascript"></script> </head><body> <select id="lucky1" onchange="return duoduo();"> <option value="1">第一期</option> <option value="2">第二期</option> </select> <div id="duoduo"> 你好</div> <input type="text" id="duo" /></body> <script type="text/javascript"> function duoduo() { $.ajax({ type: 'post', //可選get url: 'ajax.aspx', //這裡是接收資料的程式 data: 'data=' + $("#lucky1").val(), //傳給PHP的資料,多個參數用&串連 dataType: 'html', //伺服器返回的資料類型 可選XML ,Json jsonp script html text等 success: function(msg) { //這裡是ajax提交成功後,程式返回的資料處理函數。msg是返回的資料,資料類型在dataType參數裡定義! document.getElementByIdx_x_x("duoduo").innerHTML = msg; //$("#duoduo").innerHTML = msg; }, error: function() { alert('對不起失敗了'); } }) } </script> </html> 操作頁面 代碼如下: protected void Page_Load(object sender, EventArgs e) { if (Request.Params["data"].ToString().Equals("1")) { Response.Write("<a href="http://www.baidu.com">第一期</a>"); } else if (Request.Params["data"].ToString().Equals("2")) { Response.Write("<a href="http://www.baidu.com">第2期</a>"); } }