//綁定課程信息ajax
function changeDDl() {app
$.ajax({post
type: "post",ui
url: "ChangeZsdHandler.ashx",url
data: "username=" + $.trim($("#hidUserName").val()),it
datatype: "text",io
success: function (data) {function
if (data != "") {foreach
$("#ddlKc").append(data);select
}
}
});
}
<select id="ddlKc">
</select>
Ajax中代碼
if (context.Request["username"] != null)
{
username = context.Request["username"].ToString();
DataTable dt = kmbll.BindKc(username);
StringBuilder sbOptione = new StringBuilder();
sbOptione.Append("<option value='0'> ===請?選?擇?課?程¨¬=== </option>");
if (dt != null)
{
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
sbOptione.Append("<option value=\"" + dr["kmId"] + "\">" + dr["kmName"] + "</option>");
}
}
}
context.Response.Write(sbOptione.ToString());
}
else
{
context.Response.Write("");
}
context.Response.End();