title: Passing a parameter of type List to Javascript function
body: <p>I have a function in my view, that requires calling a list, in order to execute the ajax call within it. The API that I'm using has a parameter <code>List&lt;&gt;</code> among its arguments. That's why I need it.</p>
  
  <p>Is it possible to pass a parameter of type <code>List&lt;&gt;</code> to a Javascript function? If yes, what's the appropriate syntax to use? I googled and didn't find an answer yet.</p>
  
  <p>EDIT : Here's my code</p>
  
  <p>Javascript function:</p>
  
  <pre><code>    function DeleteRoom(RoomId, FloorId, userDevicesID) {
          $.ajax({
              beforeSend: function (xhr) {
                  xhr.setRequestHeader('verifySession', verifySession());
                  xhr.setRequestHeader('Authorization', '@HttpContext.Current.Session["BaseAuth"]');
              },
              url: "/api/Room/RemoveRoom?RoomId=" + RoomId + "&amp;userDevicesId="+ userDevicesID,
              type: "DELETE",
              dataType: 'json',
              success: function (data) {
                  // removing items from the view
              }
          });
      }
  </code></pre>
  
  <p>Calling the popup that uses this function: </p>
  
  <pre><code>     arr.push(existingdevices[i].attrs.id); //array of IDs, can be empty
       PopUpDeleteRoom(id, FloorId, arr);
  </code></pre>
  
  <p>The API:</p>
  
  <pre><code>    [HttpDelete]
      public void RemoveRoom(int roomId, [FromUri]List&lt;int&gt; userDevicesId)
      {
          int currentUserId = SessionData.CurrentUser.UserID;
          List&lt;Equipment&gt; equipmentsAssociated = equipmentRepository.FindMany(e =&gt; e.RoomID == roomId).ToList();
          foreach (Equipment equipment in equipmentsAssociated)
          {
              equipment.RoomID = null;
              equipmentRepository.Update(equipment);
              equipmentDeviceRepository.DeleteAllEquipmentDeviceOfZwave(equipment.EquipmentID);
          }
          foreach (int userDeviceId in userDevicesId)
          {
              userDeviceRepository.Delete(userDeviceId); 
              //this generates a NullReferenceException that I will fix later
          }
          equipmentRepository.Save();
          userDeviceRepository.Save();
          roomRepository.Delete(roomId);
          roomRepository.Save();
      }
  </code></pre>
  
  <p>Please is there a solution or a workaround for this issue?</p>