Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
I want to pass my all values to controller action method by using json.

Could you please provide the JSON and JQuery with ajax related links which are use to mvc4 application development

especially for CRUD operations.
Posted
Updated 28-May-14 3:08am
v4
Comments
karthik Udhayakumar 28-May-14 6:49am    
Where is the code?

Hi DG Kumar,

Here is a small example of an ajax call to a controller action to save data into database.
Ex :-
C#
function UpdateUserName(ID, Name) {
	var objParams = { id: ID, name:Name };
	$.ajax({
            type: "POST",
            url: { application context path } + "Common/UpdateUserName",
            data: objParams,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: true,
            success: function (response) {
                if (response != null && response != undefined) {
                    // Show success message
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                // Handle errors here
            }
        });
}


Hope this can be of help for you.


Also here some of the links to give you some correct way to do all CRUD operation using MVC & JQuery.


1) http://www.dotnet-tricks.com/Tutorial/mvc/42R0171112-CRUD-Operations-using-jQuery-dialog,-Entity-Framework-and-ASP.NET-MVC.html[^]
2) http://www.c-sharpcorner.com/Blogs/14611/insert-delete-update-read-crud-operation-in-mvc-4-0-using.aspx[^]
 
Share this answer
 
v2

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