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

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

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