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

181
Views
Replace string in js in another html page

I am trying to print on an html page the response from a REST request with JS, but when I return the string on the html page is not replaced.

JS code

                function sendDELrequest() {
                serviceID = $("#serviceID").val();
                var myurl = "/api/microservice/"+serviceID; 
                $.ajax({
                    method: "DELETE",
                    url: myurl,
                    success: function (response) {
                        Resp(response);
                    },
                });
            }

            function Resp(r) {
                resp=open("response.html").read();
                resp = resp.replace(/__RESPONSE_VALUE__/g, r.text);
                document.location.href = '/response';
                }

HTML

<head>
    <meta charset="utf-8" />
    <title>Patient Monitoring - Response</title>
    <link rel="shortcut icon" type="image/png" href="/img/healthcare.png">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css/style.css" />
</head>


<body>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <div class="container">
        <p>&nbsp;</p>
        <h3 style="text-align: center;">__RESPONSE_VALUE__</h3>
        <p>&nbsp;</p>
        <p style="text-align: center;">
        <input type="button" class="button" onclick="document.location.href='/';" value="Homepage"><br></p>
    </div>
</body>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can set only html value when getting success after ajax . Select using ID where you want to show the results

$("#id").html()
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!