I want to get the response value,but there is not response when I click the button; Why don't submit the form in asp.net?
My code:
<script type="text/javascript"> $(document).ready(function() { var options = { target: '#htmlTarget', dataType : 'json', url : 'Response.aspx', type : 'post', beforeSubmit: showRequest, success: function(msg){ alert(msg.txt + '\n\n' + msg.item); } }; $('#myForm1').ajaxForm(options); }); function showRequest(formData, jqForm,options) { return true; } $.fn.serializeNoViewState = function() { return this.find("input,textarea,select,hidden").not("[type=hidden][name^=__]").serialize(); } </script>
<form id="myForm1" runat="server"> <div id="htmlTarget"></div> <input type="text" name="txt"> <br> <input type="radio" name="item" value="A">A <input type="radio" name="item" value="B">B <input type="radio" name="item" value="C">C <input type="radio" name="item" value="D">D <br><br> <input type="submit" name="submitbtn" value="submit"> </form>
Response.cs
public partial class Response : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Expires = -1; if (Request.Form["txt"] != null && Request.Form["item"] != null) Response.Write("{txt: '" + Request["txt"] + "',item: '" + Request["item"] + "'}"); } }