Hyperlink AJAX updated ID

function Submit(handlerUrl, formElement) {
  if (validate()) {
    const xhr = new XMLHttpRequest();
    xhr.open('POST', handlerUrl, true);
    xhr.onload = function () {
      if (xhr.status === 200) {
          if (xhr.responseText.match(/^username/)) {
          const name = xhr.responseText.replace(/^username/, "")
          document.getElementById("Username").textContent = name;
          alert("Your information has been saved");
        } else {

    xhr.send(new FormData(formElement));
URL is: https://domainname.com/<span id="Username"><%=rs ("username")%></span>

I am using AJAX to update the URL after clicking save. Works fine, no issues there!
What I can’t seem to do is to have the url with username (as above) to place it on the same page with it hyperlinked. Something like this:

<a href = "https://domainname.com/<span id="Username">"<%=rs ("username")%></span>VIEW</a>

This obviously doesn’t work but I don’t know how to fix it. Any help would be appreciated.


I tried this, with the span on the outside, but the update doesn’t work. So not sure if it requires a different span id name?

<span id="Span id="Username"><a href="https://domainname/<%=rs ("username")%>">VIEW</a></span>

Instead of trying to set the content of a span inside another element, why don’t you try setting the href attribute of the link tag?

Not sure how to do that because this was the only way I was able to get it to hyperlink. Can you explain. Thanks for your reply.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.