Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
How to send POST request from login page?

I have a html select for switching languages on the site.

<div class= "langselect">
    <select id ="select" onchange="changeLang()">
            <option disabled selected><%: GlobalInterpreter.GetTranslate("Shared", "Language") %></option>
            <option value="en"><%: GlobalInterpreter.GetTranslate("Shared", "English") %></option>
            <option value="ru"><%: GlobalInterpreter.GetTranslate("Shared", "Russian") %></option>
            <option value="es"><%: GlobalInterpreter.GetTranslate("Shared", "Spanish") %></option>
            <option value="fr"><%: GlobalInterpreter.GetTranslate("Shared", "French") %></option>
        </select>
</div>

And here's js code for changing:

<script type="text/javascript">
    function changeLang () {
        element = document.querySelector('#select');
        console.log(element.value);

        $.post("<%:Url.Action("SetLang", "Account")%>", { lang: element.value });
        location.reload();
        };
</script>

Controller function:

[HttpPost]
public ActionResult SetLang(string lang)
        {
            ...user_lang = lang;
            return new EmptyResult();
        }

So the problem is the same as it was in my previous question (Why does POST request to controller not work?) — the method is not called when I send POST from login page. So now I'm not trying to work with data before page is loaded, I'm just trying to change site language on the login page according to user's choice. What can be the problem with POST? Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda