日期:2014-05-18  浏览次数:20417 次

asp.net Jquery xml ajax提交怎么我这样写无法传递参数?
data: {"HOMEMANAGENOTE_ID":$("#Text1").val()},

使用这种方式竟然无法传递参数,各位有知道原因的告诉一下啊。

这样写也不行: data: "{HOMEMANAGENOTE_ID:"+$("#Text1").val()+"}",

到底该如何写才能用啊??



------解决方案--------------------
测试页面

<%@ Page Language="C#" %>

<!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 id="Head1" runat="server">
<title>Untitled Page</title>
<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function myfunction() {
$.ajax({
type: "Post",
url: "ResponsePage.aspx",
data: { "HOMEMANAGENOTE_ID": $("#Text1").val() },
dataType: "xml",
success: function (xhr) {
$(xhr).find('data').each(function () {
alert($(this).text());
});
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="Text1" value="aaa" />
<input type="button" value="直接点击测试 " onclick="myfunction()" />
</form>
</body>
</html>


ResponsePage.aspx
<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Response.ClearContent();
Response.ContentType = "text/xml";
Response.Write("<data>" + Request.Form["HOMEMANAGENOTE_ID"] + "</data>");
Response.End();
}
</script>