I have html code snippet below, It will not display anything in the div "itemContent" unless I type it in. I can debug and I can tell that the appropriate data is getting passed to the "sucessfil", however nothing shows up on the div it appends! Is there anything wrong with my 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 this code. It takes the href attribute from a link class type item and send it to 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>
精彩评论