日期:2014-05-17 浏览次数:20496 次
<script language="javascript" type="text/javascript">
$(function(){
$("#Button1").click(function(){
$.post("text.aspx",{Action:"post",timeBegin:$("#TextBox1").val(),timeEnd:$("#TextBox2").val()}
,function(data){
document.getElementById("mydiv").innerHTML="<font color='red'>"+ data + "</font>";
},"json" );
});
});
</script>
<form id="form1" runat="server">
<div>
起始日期:<asp:TextBox ID="TextBox1" class="mydate" runat="server"></asp:TextBox>
截止日期: <asp:TextBox ID="TextBox2" class="mydate" runat="server"></asp:TextBox>
</div>
<input id="Button1" type="button" value="提交" />
</form>
<div id="mydiv">
</div>
protected void Page_Load(object sender, EventArgs e)
{
string timeBegin = Request.Form["timeBegin"];
string timeEnd = Request.Form["timeEnd"];
Response.ContentType = "text/plain";
Context.Response.Write("success!");
Response.End();
}
$(function(){
$("#Button1").click(function(){
$.post("text.aspx",{"Action":"post","timeBegin":$("#TextBox1").val(),"timeEnd":$("#TextBox2").val()}
,function(data){
document.getElementById("mydiv").innerHTML="<font color='red'>"+ data + "</font>";
},"json" );
});
});
------解决方案--------------------
"json" 你的反回值不是JSON 换成"text" 看看