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

83
Views
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 answers
Answer question

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