خرید بک لینک

Vote count: 0

Iam Not expecting retuing result when i call the server, Iam just passing inputs to actionResult which will use it to create a new object and insert it to database using entityFramework.

 <script>
    $(document).ready(function () {  
        $("#Add").click(function () {
            var EmployeeeId = $("#EmployeeId").val();
            var Phone =$("#Phone").val();
            var Email = $("#Email").val();
            var Address = $("#Address").val();


        var UserModel =
{
    "EmployeeId": EmployeeeId,
    "Phone": Phone,
    "Address": Address,
    "Email": Email

};    $.ajax({url: '@Url.Action("AddNewContactList","Home")',


            type: "POST",
            dataType: "json",

            data: JSON.stringify(UserModel),
            contentType: 'application/json; charset=utf-8',


                        success: function (result) {

                           //Doesnt Matter

                        },
                        error: function (xhr, ajaxOptions, thrownError) {

                            alert("Failed");
                        }

And here is my Controller Code

And this is my controller action being called

 [HttpPost]
    public ActionResult AddNewContactList(ContactList c)
    {DbContext m = new DbContext();


        m.ContactList.Add(c);

        m.SaveChanges();



        retu View();



}

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 27 ارديبهشت 1395 ساعت: 18:24

صفحه بندی