简体   繁体   中英

Cannot show div popup even after a successful ajax post

I have a div

<div id="pop2" class="pop-up1" style="display:none;">
  <div class="popBox1">
    <div class="popScroll1">
      <h2></h2>
      <p id="p1_id"></p>
    </div>
    <a href="#links" class="close"><span>Close</span></span></a>
  </div>
  <a href="#links" class="lightbox1">Back to links</a>
</div>

I have an external file edit_invoice_details.php in which I want to post some data which I am doing through this jquery function

<script>
    $(document).ready(function(){
    $('table tbody tr').dblclick(function(){
        //alert($("#myId2").text());
        //showeditDiv($( "#myId2" ).text());
        var invid=$("#myId2").text();
        var pid=$("myId").text();
        var dataString = 'inv_id='+ invid+'prod_id='+pid;
        $.ajax({
        type: "POST",
        url: "edit_invoice_details.php",
        data: dataString,
        cache: false,
        success: function(html)
        {           
            alert("success");
            $("#pop2").show();
            $("#p1_id").html(html).show();
        }
        });
    });
});
</script>

I want such a table such that when someone double clicks on it the div should open. Success alert is working fine. but I am not able to show that div. The divs content should be edit_invoice_details.php. Response text maybe

Any help is appreciated

Try this:

$("#pop2").style.display = "block";

if it dont work then there might be other problems. Let me know.

sometimes if you hardcode the property display in the html tag like you did here

<div id="pop2" class="pop-up1" style="display:none;">

when you tried to show the div it won't work, try set the display to none in the css instead of hardcode the css in the html tag, that happened to me and I fixed that way.

also with this code

   $("#p1_id").html(html).show();

you are now showing the #p1_id selector, you are showing what is inside the #p1_id, tried some like

$("#p1_id").html(html);
$("#p1_id").show();

let me know if works for you the two possible issues that I wrote.

我想你需要使用& here:

var dataString = 'inv_id='+ invid+'&prod_id='+pid;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM