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

244
Vistas
How do I write Ajax syntax to retrieve data from an SQL database

I am trying to retrieve a particular column in my SQL database using Ajax, Javascript to a button without refreshing the whole page but only the button. I am new to Javascript and AJAX. How can I achieve that. I am using MVC.

    function GetId()
    {
        $("#display").onclick(function(){
        $.ajax({
            type: "POST",
            url: "Default.asp/Connection",
            data: "{}",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            success: OnSuccess,
            error:OnError,

            success: function(data){
                displaybuttonFromDatabase();
            }
        });

    }
    function OnSuccess(data){
        var TableContent = "<table border = '0'>" +
                        "<tr>" +
                            "<td>Employee_Identification_No</td>" +
                        "</tr>";

        for(var i = 0; i<data.d.length;i++)
        {
            TableContent += "<tr>" +
                                "<td>" + data.d[i].Employee_Identification_No + "</td>" +
                                "<td></td>" +
                            "</tr>";

        }

        TableContent += "</table>";

        $("#UpdatePanel").html(TableContent);

    }
    function OnError(data) {

    }

    function displaybuttonFromDatabase() {
        $.ajax({
            url: "server",
            type: "POST",
            asyn: false,
            data: {
                "display": 1
            },
            success: function(data){
                $("#display").html(data);
            }
        })
    }
    });

I have also tried activating the button upon the click event. Tried this code

 function loadmyStaffData()
    {
      var name = document.getElementById("Employee_Identification_No");

       if (name != null)
        {
            $.ajax({
                type: 'post',
                url: '',
                data: {
                    Employee_Identification_No: name,
                },
                success: function(response){
                    $('#display').Html(response);
                }
            });
        }
        else
        {
            $('display').html('Re click this box')
        }
    }
about 4 years ago · Santiago Trujillo
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