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

81
Vistas
How to use JavaScript or Jquery to dynamically changes HTML text input

I have a web service that returns a string. https://localhost:5001/mywebservice

Now, I made a HTML page with a text input. I'd like to use to JavaScript or JQuery to call my webservice. Then update the text input with whatever returns from my web service https://localhost:5001/mywebservice

I tried to use the following JQuery code snippet. But it won't work.

$('button').on('click', function (e) {
    var str = $('https://localhost:5001/mywebservice').val();
    $("#MyString").prop('value', str);
});

I'd appreciate it if someone can give me a hint. Thank you for your help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

ok, so first of all, you did the event listener right. If this script runs within the HTML file, then you can select elements from the document. Use

$("<select your input>").val() 

if it is a text box or .html() if it is an element. To request the return info of your service, do not use jquery $. it was not built to ajax.

  1. make sure it is always up and running when you use the platform
  2. Instead of hosting it on localhost, try running it on whatever platform this js is on.
  3. make the localhost only display the info you are sending back
  4. send an ajax call to your localhost website, use
$.ajax({
url:"https://localhost:5001/mywebservice",
success:function(d){
//d is your data
}
})
about 4 years ago · Juan Pablo Isaza Denunciar
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