色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

jquery 獲取json數(shù)據(jù)實(shí)現(xiàn)代碼

復(fù)制代碼 代碼如下:
//欄目
//發(fā)送ajax請(qǐng)求
$.getJSON(
"../../../Templet/GetInfoHandler.ashx", //產(chǎn)生JSON數(shù)據(jù)的服務(wù)端頁(yè)面
{id: "0", sid: "1;2;3", rid: Math.round(Math.random() * 10) }, //向服務(wù)器發(fā)出的查詢(xún)字符串
//對(duì)返回的JSON數(shù)據(jù)進(jìn)行處理
function(json) {
//循環(huán)取json中的數(shù)據(jù),并呈現(xiàn)在列表中
$("#column_0_1").empty();
var colstr = '<h2><span><a href="#" href="#">更多>></a></span>熱門(mén)招聘</h2><ul>';
$.each(json, function(i) {
//alert(json[i].news_id);
colstr = colstr + '<li><a + json[i].new_file_name + '" + json[i].new_file_name + '">' + json[i].news_title + '</a></li>';
})
colstr = colstr + '</ul>';
$("#column_0_1").html(colstr);
alert("加載成功");
// })

用Litjson生成json數(shù)據(jù)的C#程序:
復(fù)制代碼 代碼如下:
//欄目
//發(fā)送ajax請(qǐng)求
$.getJSON(
"../../../Templet/GetInfoHandler.ashx", //產(chǎn)生JSON數(shù)據(jù)的服務(wù)端頁(yè)面
{id: "0", sid: "1;2;3", rid: Math.round(Math.random() * 10) }, //向服務(wù)器發(fā)出的查詢(xún)字符串
//對(duì)返回的JSON數(shù)據(jù)進(jìn)行處理
function(json) {
//循環(huán)取json中的數(shù)據(jù),并呈現(xiàn)在列表中
$("#column_0_1").empty();
var colstr = '<h2><span><a href="#" href="#">更多>></a></span>熱門(mén)招聘</h2><ul>';
$.each(json, function(i) {
//alert(json[i].news_id);
colstr = colstr + '<li><a + json[i].new_file_name + '" + json[i].new_file_name + '">' + json[i].news_title + '</a></li>';
})
colstr = colstr + '</ul>';
$("#column_0_1").html(colstr);
alert("加載成功");
// })

jquery通過(guò)json獲取數(shù)據(jù)
復(fù)制代碼 代碼如下:
<script type="text/Javascript">
$(document).ready(function () {
getScatalog("paidang", "M06");
});
function getScatalog(selectid,BaseCode) {
if (BaseCode != "") {
$.ajax({
url: "ajax/getCatalogByBasecode.ASPx",
data: "code=" + encodeURI(BaseCode), cache: false,
datatype: "html",
success: function (context) {
fillselect(selectid, context);
}
});
}
else {
return "Error";
}
}
function fillselect(selectid, context) {
var listitem=new Array();
listitem = eval(context);
for (var i = 0; i < listitem.length; i++) {
$("#" + selectid).append("<option value='" + listitem[i]["code"] + "'>" + listitem[i]["name"] + "</option>"); //為Select追加一個(gè)Option(下拉項(xiàng))
}
}
</script>

html代碼:
復(fù)制代碼 代碼如下:
<select id="paidang" class="selectstyle" name="paidang">
<option value="" selected>==請(qǐng)選擇==</option>
</select>

Ajax:
新建一個(gè).ASPx頁(yè)面刪除.ASPx頁(yè)面里的html代碼刪除,在.ASPx.cs里添加如下代碼
復(fù)制代碼 代碼如下:
string rq_basecode=null;
rq_basecode = Request.QueryString["code"];
if (string.IsNullOrWhiteSpace(rq_basecode))
{
Response.Write("Error");
Response.End();
}
BLLCataLog bll_info = new BLLCataLog();
List<Scatalog> lt_info = new List<Scatalog>();
lt_info = bll_info.GetCatalog(rq_basecode,"");
//Response.Write(rq_basecode);
if (lt_info.Count > 0)
{
Response.Write(JsonHelper.ToJson(lt_info));
}
else
{
Response.Write("Null");
}

BLL層的數(shù)據(jù):
復(fù)制代碼 代碼如下:
public List<M2Model.Scatalog> GetCatalog(string code, string refcode)
{
DALCataLog dalcatalog6 = new M2SharpDAL.DALCataLog();
return dalcatalog6.GetCatalog(code, refcode);
}

JavaScript技術(shù)jquery 獲取json數(shù)據(jù)實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 阿瓦提县| 纳雍县| 芦溪县| 义乌市| 山阴县| 马尔康县| 庐江县| 竹山县| 九龙县| 淮安市| 合阳县| 墨脱县| 阆中市| 平安县| 宽甸| 筠连县| 政和县| 阿荣旗| 宣化县| 通许县| 武安市| 建昌县| 信宜市| 大埔区| 洮南市| 滦平县| 怀宁县| 白银市| 克拉玛依市| 宁南县| 昌邑市| 武冈市| 益阳市| 延津县| 友谊县| 五原县| 岚皋县| 望城县| 石阡县| 永嘉县| 仁怀市|