1

i have list of objects :

var things = [];
var obj = {
            ayah: line.ayah,
            surah: line.surah,
            verse: line.verse
          };
          things.push(obj); 

$.ajax({
         method: 'GET',
         url: "Gateway/Inbound_Request_Handler?action=1",
         data:things,
         success: function (Data) {
         var mera_obj = Data.key;
         document.getElementById("Param2").value = '(' + mera_obj.Response_Code + ' , ' + mera_obj.Response_Description + ')';
         },
         error: function () {
         alert("ERROR: can't connect to Server this time");
                   }
               });

and class :

public class thing {
        public int surah { get; set; }
        public int ayah { get; set; }
        public string verse { get; set; }

    }

and here is controller method :

public class GatewayController : Controller
    {
        [HttpGet]
        public ActionResult Inbound_Request_Handler(List<thing> things)
        {...}
    }

but its still showing that list in controller method is null. i don't know whats wrong with me ?

Marium
  • 1
  • 4

1 Answers1

1

Your ajax call specifies data

Change data:things to data: {things: things} to specify the name of the object passed in, so MVC can bind to it.

Alex
  • 37,502
  • 51
  • 204
  • 332