Estoy tratando de imprimir en una página html la respuesta de una solicitud REST con JS, pero cuando devuelvo la cadena en la página html no se reemplaza.
codigo js
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> </p> <p> </p> <div class="container"> <p> </p> <h3 style="text-align: center;">__RESPONSE_VALUE__</h3> <p> </p> <p style="text-align: center;"> <input type="button" class="button" onclick="document.location.href='/';" value="Homepage"><br></p> </div> </body>Puede establecer solo el valor html cuando tenga éxito después de ajax. Selecciona usando ID donde quieres mostrar los resultados
$("#id").html()