Home > front end >  Ajax receives response as should but does not show on page
Ajax receives response as should but does not show on page

Time:02-27

I need to figure out something with AJAX , express and Node.

  • my Ajax request receives data and logs suggest that they are there
  • they are not showing on the page

Here are the functions : Ajax request :

let openSingle = async function (par) {
    $.ajax({
        url: targetEnvironment   '/v1/flashmsg/'   par,
        dataType: 'json',
        type: 'get',
        data: JSON.stringify(par),
        beforeSend: function (xhr) {
            xhr.setRequestHeader("x-access-token", localStorage.getItem('token'));
        },
        contentType: 'application/json',
        success: function (data, textStatus, jQxhr) {
            console.log("Row <"   JSON.stringify(data)  "> data retrieved successfully"); //shows ok
          $("#par").html("<b>displayed data is</b>"   JSON.stringify(data)); 
        },
        error: function (jqXhr, textStatus, errorThrown) {
            switch (jqXhr.status) {
                case 401:
                    document.location.href = "/index.html";
                    break;
            }
        }
    });
};

HTML (problem at h5 -> line 13)

<div  id="parModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
  aria-hidden="true">
  <div  role="document">
    <div >
      <div >
        <h5  id="parTitle"></h5>
        <button type="button"  data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form role="form">
        <div >
          <h5 id=#par></h5>
        </div>
        <div >
          <button type="button"  data-dismiss="modal">Cancel</button>
          <button type="submit"  id="saveAstreinteNum">Save</button>
        </div>
      </form>
    </div>
  </div>
</div>

CodePudding user response:

Curtesy of @MarkRobson : remove # on html ->

CodePudding user response:

Looks like it’s just a typo.

You have:

It should be:

  • Related