Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
View In mvc
HTML
<script type="text/javascript">
    function SubmitInfo(formContainer) {
        alert("in fun");
        alert(formContainer.serialize());
        $.ajax({
            url: "User/Index",
            type: 'post',
            data: formContainer.serialize(),
            success: function(data) {
                if (data.IsSuccess) {
                    // Clear the input tags
                    formContainer.find("input[type='text']").each(function (i, element) {
                        $(this).val('');
                    });
                }
                alert("giii");
                alert(data.Message);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(errorThrown);
            }
        });
}
</script>

Controller part. My i print responsr.write(jsonArray) It gives the above error
C#
[HttpPost]
        public JsonResult Index(User model)
        {
            if (ModelState.IsValid)
            {
                JArray JsonArray = new JArray();
                JObject jo = new JObject();
                User puser=new User();
                puser.USER_NAME = model.USER_NAME.Trim();
                puser.EMAIL_ID = model.EMAIL_ID.Trim();
                puser.MOBILE_NO = model.MOBILE_NO.Trim();
                List<User> tUser = new List<Models.User>();
                tUser.Add(puser);
                //GetPageBaseObject.Add(puser);

                JsonArray = (JArray)JToken.FromObject(tUser);//.Replace(new Regex("\\n", "g"),"");
               
                Response.Write(JsonArray);

                jo["Message"] = "Data Saved Succeffully";
                jo["data"] = JsonArray;

                Response.Write(jo.ToString());
                return Json(jo["data"]);
            }
            else
            {
                return Json(false);
            }
        }
    }
}
Posted
v2
Comments
Member 10435696 10-Feb-14 4:55am    
what are u editing???plz let me know???
Sampath Lokuge 11-Feb-14 3:19am    
Why do you need to do this (i.e Response.Write())? Without that just check the array values by using debugger on Visual studio ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900