Jquery append/html div not functioning, wrong css? -
i have html code snippet below, not display in div "itemcontent" unless type in. can debug , can tell appropriate data getting passed "sucessfil", nothing shows on div appends! there wrong css?
<script type="text/javascript"> function sucessfil(data) { $('#itemcontent').append(data); } function displayitem(param) { $.ajax({ url: 'itemviewer.php?id='+param, success:sucessfil }); } function showiteminviewer(param) { el = document.getelementbyid("itemviewer"); el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; if(param!='') { displayitem(param); } } </script> <style> #itemviewer { visibility: hidden; position: absolute; left: 20%; top: 5px; width: 500px; height: 500px; text-align: center; z-index: 1000; background-color:#666 } #itemviewer div { width: 500px; height: 500px; background-color: #fff; border: 1px solid #000; border-color:#f30 padding: 4px; text-align: center; } </style> <a href='#' onclick="showiteminviewer('57');" >thrilled</a> <div id="moodviewer"> <div id="moodcontent"> <img href='#' onclick="showiteminviewer('');" src="images/exit.png" align="right"></img> </div>
try code. takes href attribute link class type item , send itemviewer.
$('a.item').live('click',function(event) { $.ajax({ type:'post', url:'itemviewer.php', data:'id=' + $(this).attr('href'); sucess: function(data) { $('#itemcontent').append(data); } }); event.preventdefault(); } html, example:
<a class="item" href="57">item x</a> <a class="item" href="45">item y</a> <div id="itemcontent"></div>
Comments
Post a Comment