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

85
Visualizações
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 Respostas
Responde à pergunta

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 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