mardi 4 août 2015

"POST" data with jquery ajax and MVC2

I'm using MVC2, and I'm trying to send data with jquery ajax.

There is my JS code:

$.ajax({
                      type: "POST",
                      url: "Data",
                      data: { processName: "MyProc", startDate: "2015-08-01 16:00"},
                      success: function(data) {
                      }
                    });

And there is my controller:

[HttpPost]
        public JsonResult Data(string processName,string startDate)
        {
           int i = 1;
         }

So my problem is that I DO get to "int i=1;" line in my controller, BUT for some unknown reason - processName and startDate are both null.

Can someone please assist ?

Aucun commentaire:

Enregistrer un commentaire