Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Jquery - MVC - El nombre de la función no está definido en HTMLButtonElement.onclick

Busqué este error y probé la solución de otras personas, pero no se solucionó. Cambié las versiones de jquery, escribí el código desde el principio vs vs pero sigue siendo el mismo.

 [HttpPost] public JsonResult GetID(int ID) { List<User> users = db.users.ToList(); User user = users.FirstOrDefault(x => x.Id == ID); return Json(user, JsonRequestBehavior.AllowGet); } <button onclick="dataget()" id="personID" style="margin-left: 28%;"> <span class="fa fa-arrow-left text-dark" style="font-size:30px" aria-hidden="true"></span></button> <script type="text/javascript"> var dataget = function () { var ID = 1; $.ajax({ url: '/Finder/GetID/' + ID, type: 'POST', dataType: 'json', success: function (data) { $("#Name").html(data.Name); $("#Surname").html(data.Surname); } }); </script>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use esto como su botón;

 <button id="personID" style="margin-left: 28%;"> ... </button>

Debe colocar su secuencia de comandos dentro de una sección de afeitar, se insertará en la sección de secuencias de comandos en su diseño.

 @section script { <script type="text/javascript"> // execute this function upon page ready $(document).ready(function(){ // bind the event to your button $("#personID").click(function(e){ e.preventDefault(); //Fetch form data var sendData = { ID:1 }; $.ajax({ url: '@Url.Action("Find","GetID")', type: 'POST', data: sendData, dataType: 'json', contentType: 'application/json; charset=utf-8', success: function (data) { $("#Name").html(data.Name); $("#Surname").html(data.Surname); } }); }); }); </script> }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!