Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Why would my array on my MVC Controller be null on Ajax Postback

Here is my array:

{latlng: [{lat: 41.9841092242239, lng: -87.6459866168}, {lat: 41.948650308164744, lng: -87.64431828280067}, {lat: 41.94833112697515, lng: -87.644017875391}]

Here is my javascript code:

  var postedData = JSON.stringify({
                latlng: boundaries
            });

            alert("here are your boundaries so far : " + postedData);

            $.ajax({
                url: '/Communities/UpdateBoundaries',
                type: "POST",
                traditional: true,
                contentType: "application/json",
                data: postedData,
                datatype: "json",
                success: function () {
                    console.log('success!!');
                }
            });
        }

and here is my controller: where boundaries is my incoming array of latlng, but it is coming in null.

   [HttpPost]
    public ActionResult UpdateBoundaries(List<latLng> boundaries)
    {
        return View();
    }
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Change

var postedData = JSON.stringify({latlng: boundaries});

to

var postedData = JSON.stringify(boundaries);

This is because the action parameter is an array. If it were a type that contained an array property with property name latlng then you pass it in the same manner you did in your existing code.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda