0

I'm sending a call like so:

$.ajax({
            url: myURL+functionName,
            contentType: "application/json; charset=utf-8", //also tried application/javascript
            cache: false,
            dataType: "jsonp",
            data: parameter,
            success:function(response){
                alert("great success!");
            },
            error:function(error) {alert("boo-urns");}

Which is fine and everything looks like it should. The parameter object comes in with a value like so:

{ac:"a8d8e6ef-5907-4978-11cf-39add52b996c",
date:"20160626",
deviceId:"W-eXXX9680-13X3-9317-f1b3-eXXXXe50",
komponenten:Array[5],
menu_kf_nr:1,
mz_nr:"3",
pt_kf_nr:1,
pt_nr:"311701",
sessionId:"b22bXXX6-20XX-4XXX-9ed6-0dXXb297"}

Here is the server side method:

public bool functionName(string ac, string date, string deviceId, List<komponenten> komponenten, int? menu_kf_nr, string mz_nr, int pt_kf_nr, string pt_nr, string sessionId) {
    //do stuff with the data 

}

And then on the server side though my params only come as follows:

ac  "a8d8e6ef-5907-4978-11cf-39add52b996c"  string
date    "20160626"  string
deviceId    null    string
komponenten null    System.Collections.Generic.List<kompnenten>
menu_kf_nr  null    int?
mz_nr   "3" string
pt_kf_nr    1   int
pt_nr   "311701"    string
sessionId   null    string

Can anyone tell me where I need to look in order to eliminate the nulls?

Thanks in advance

rory
  • 1,490
  • 3
  • 22
  • 50

1 Answers1

0

You should pass your parameters individually in the aJax call, also, the C# side is probably expecting JSON data to be received.

Take a look here to see how to pass multiple parameters in an aJax call.

Note the second part of the accepted answer, using JSON.Stringify

Community
  • 1
  • 1
pay
  • 366
  • 3
  • 18