function postForm()
{
$.ajax({
type: "POST",
data: $("#myForm").serialize(),
dataType: "json",
url: '<%= Url.Action("JSONRequest","Home") %>',
success: function(result)
{
window.alert(result.name);
},
error : function()
{
window.alert('error');
}
});
}
Html.BeginForm("JSONRequest", "Home", FormMethod.Post, new { id = "myForm" });
Html.TextBox("mazhar")
<input type="submit" onclick="postForm" />
Html.EndForm();
public ActionResult JSONRequest(FormCollection form)
{
string a = form["mazhar"];
var data = new { name = "aaaa", Success = "Record is Succesfully Saved", ErrorMessages = "abc" };
return Json(data);
}
Ok the problem is that the dialog box is opening after running this code which is asking to save file. Can someone tell me how to resolve this issue? Why does this box comes afterall?