如果任何人单击图像而不是仅单击图像 sl 编号传递到 php 页面,我想这样做。但我没有得到任何 imge sl 号码。我试图找出问题所在。但我不能请,任何人帮助我。谢谢。这是我的代码
<?php
$query="select * from image_content order by sl";
$result=mysql_query($query) or die (mysql_error());
$num=mysql_num_rows($result);
for ($i=0; $i<$num; $i++)
{
$sl=mysql_result($result, $i, "sl");
$title=mysql_result($result, $i, "title");
$image_name=mysql_result($result, $i, "image_name");
echo"
<div id='image_style'>
<div id='upload_image'>
<a class='picture_description' href='#' title='$title'>
<img src='../download/$image_name' />
<div align='center'>Title: $title</div>
</a>
</div>
<input type='hidden' class='picture_sl' name='picture_sl' value='$sl'/>
</div>";
}
?>
jQuery代码:
<script type="text/javascript">
$(document).ready(function() {
$(".picture_description").click(function() {
var action = $("#form1").attr('action');
var form_data = {
picture_sl: $(".picture_sl").val(),
is_ajax: 1
};
$.ajax({
type: "POST",
url: action,
data: form_data,
success: function(response)
{
$("#div_1").html(response);
}
});
return false;
});
});
</script>
加载的php:
<?php
echo $picture_sl=$_POST['picture_sl'];
?>