Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

how to post value on POST method in MVC c#. after post value it returns with value from server on MVC. i need solution for this asap. pls send some samples or link.

here below code for post value in server using knockoutjs.

code:

C#
var items = ko.toJSON(self.empnamee);
     alert(items);
     $.ajax({
         type: "POST",
         url: "http://192.170.1.01/API1/api/home"+self.empnamee,

         data: items,
         processData: false,
         success: function (data) {
             alert('success');
         },
         statusCode: {
             404: function () {
                 alert('Failed');
             }
         }
     });
Posted

1 solution

Hello Mohan,
SQL
First up all concentrate on principle for calling action and controller in MVC.  Currently as per your code you are calling url "http://192.170.1.01/API1/api/home"+self.empnamee" ,  Now here for time being I assume that "api" is your controller and "home" is your action. But here in your code looks like that your action name is changing with respect to employee name. This would now going to work for you.
    By taking again your url as an example,  http://192.170.1.01/API1/api/home. Now here api will be controller, home become action, and self.empnamee should be parameter for your action. One more important thing you have been used API1 in url so that you should be make an entry to RouteConfig.cs as routes.MapRoute("AjaxCall", " API1/{controller}/{action}/");
I hope this will help you
 
Share this answer
 

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