asp.net mvc json open dialog box problem

Posted by mazhar kaunain baig on Stack Overflow See other posts from Stack Overflow or by mazhar kaunain baig
Published on 2010-06-02T10:42:43Z Indexed on 2010/06/02 10:43 UTC
Read the original article Hit count: 316

Filed under:
|
|
|
 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?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript