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

159
Visualizações
AJAX and c# mvc controller get bool

I have been stuck at this for some time now. I am trying to send a bool from my controller to the view through ajax. I tried several different tutorials and methods but can't seem to be able to retrieve some simple data. I was hoping somebody can explain what am I doing wrong.

Here is my code:

Ajax:

$(document).ready(function () {

$.ajax({
    "url": "/social/checkfollow",
    "type": "GET",
    "dataType": "json",
    "success":function(data) {

        console.log(data);
    },
    "error": function(data) {
        console.log(data.status +" "+ data.statusText);
    }
});

});

And the controller:

   [HttpGet]
    public virtual ActionResult CheckFollow()
    {
        var pass = false;

        return Json(new {result = pass});
    }

For some reason i keep getting 500 Internal Service error. i know it's a really basic question and i would really appreciate your help.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Your return statement probably should be:

return Json(new {result = pass}, JsonRequestBehavior.AllowGet);

Pertinent explanation of the AllowGet: Why is JsonRequestBehavior needed?

over 4 years ago · Santiago Trujillo Relatório

0

Return statement not properly for pass json so i have add sample code so try it and let me know any problem.

[HttpGet]
public virtual ActionResult CheckFollow()
{
    var pass = false;

    return Json(new {result = pass}, JsonRequestBehavior.AllowGet);
}
over 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