请求也代码:<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script src="../js/jquery-1.3.2.max.js" type="text/javascript"></script>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/jscript"></script>
<script language="javascript" type="text/javascript">
$(function(){
var url = "actionUser.aspx";
$.post(url, function(returnvalue)
{
alert(returnvalue);
$("#sheng").append(returnvalue);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<select id="sheng">
</select>
</div>
</form>
</body>
</html>actionUser.aspx:string select = "select * from sheng";
DataTable dt = DBHelper.GetTable(select);
string htmltext = string.Empty;
bool isfirst = true;
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
if (isfirst)
{
htmltext += "<option value=\"" + row[0].ToString() + "\" selected=\"selected\">" + row[1] + "</option>";
isfirst = false;
}
else
htmltext += "<option value=\"" + row[0].ToString() + "\">" + row[1] + "</option>";
}
}
Response.Write(htmltext);为什么添加不上去呢?,htmltext值是:<option value="1" selected="selected">安徽</option><option value="2">江苏</option>
<head runat="server">
<title>无标题页</title>
<script src="../js/jquery-1.3.2.max.js" type="text/javascript"></script>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/jscript"></script>
<script language="javascript" type="text/javascript">
$(function(){
var url = "actionUser.aspx";
$.post(url, function(returnvalue)
{
alert(returnvalue);
$("#sheng").append(returnvalue);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<select id="sheng">
</select>
</div>
</form>
</body>
</html>actionUser.aspx:string select = "select * from sheng";
DataTable dt = DBHelper.GetTable(select);
string htmltext = string.Empty;
bool isfirst = true;
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
if (isfirst)
{
htmltext += "<option value=\"" + row[0].ToString() + "\" selected=\"selected\">" + row[1] + "</option>";
isfirst = false;
}
else
htmltext += "<option value=\"" + row[0].ToString() + "\">" + row[1] + "</option>";
}
}
Response.Write(htmltext);为什么添加不上去呢?,htmltext值是:<option value="1" selected="selected">安徽</option><option value="2">江苏</option>
哥们,帮你顶下,兄弟我今天也被jquery的几行代码搞的好郁闷的。
你将整个html都返回啦。。
在pageload里加上下面这句。 Response.ContentType = "text/plain";
将aspx的代码去掉,只留第一行
Response.ContentType = "text/plain";
Response.Write(htmltext);