user6410893 user6410893 - 4 months ago 67x
HTML Question

jQuery Show/Hide Div as per the ajax response and pass the response's requestId to the success Div

I have the below code for show/hide success div as per the service call's response plus i need to pass the Service Response's request to the Success

. How do i pass the
and show the success

<div id="showResponseArea" class="alert alert-success hide">
<strong>Success !! </strong>Your request <<requestId>> has been successfuly created !!!

success: function(resObj){
$("#showResponseArea span").removeClass("hide");
var requestId = resObj.requestId;
error: funciton(resObj){
alert("Some Error Occured");


First of all you are removing the hide class from wrong TAG span which does not have that class. hide class should be removed from from the parent div with id="showResponseArea" which has the hide class, secondly You need to wrap the <<requestId>> in span with an id. like

<div id="showResponseArea" class="alert hide">
    <strong>Success !! </strong>Your request <span id="requestId"> // Request id goes here</span> has been successfuly created !!! 

Then in the ajax success function

success: function(resObj){
    //OR $("#showResponseArea").removeClass("hide").show();

    var requestId = resObj.requestId;   
    $("#requestId").text(requestId ); 
error: function(err,xhr,status){
    //OR $("#showResponseArea").removeClass("hide").show();