我希望将在图像上生成的注释存储在数据库中。我使用了声名狼藉的API来生成注释。API说:
有些版本与jQuery冲突臭名昭著。当在同一个页面上使用alias和jQuery时,您应该将jQuery置于无冲突模式,或者为jQuery的$别名分配一个新的变量名,或者将jQuery代码包装成一个函数,在这个函数中您可以在本地范围中使用$别名,
就像这样:
jQuery.noConflict();
jQuery(document).ready(function($) {
// You can use the locally-scoped $ in here as an alias to jQuery.
$('div').hide();
});myAnnotations.php:
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
jQuery.noConflict();
</script>
<script type="text/javascript" src="annotorious.min.js"></script>
<link type="text/css" rel="stylesheet" href="css/theme-dark/annotorious-dark.css" />
<script>
anno.addHandler('onAnnotationCreated', function(annotation) {
var anno_text = annotation.text;
var anno_x =annotation.shapes[0].geometry.x;
var anno_y = annotation.shapes[0].geometry.y;
var anno_width = annotation.shapes[0].geometry.width;
var anno_height= annotation.shapes[0].geometry.height;
jQuery.post("insert-note.php",
{anno_text:anno_text,anno_x:anno_x,anno_y:anno_y,anno_width:anno_width,anno_height:anno_height}
);
});
</script>insert-data.php:
<?php
$anno_text = $_POST['anno_text'];
$anno_x = $_POST['anno_x'];
$anno_y = $_POST['anno_y'];
$anno_width = $_POST['anno_width'];
$anno_height = $_POST['anno_height'];
$sql = "insert into `notes`(`note`,`annox`,`annoy`,`anno_width`,`anno_height`) VALUES ('$anno_text','$anno_x','$anno_y','$anno_width','anno_height')";
$sql_query = mysqli_query($dbcon, $sql) or die(mysqli_errno($dbcon));
?>这既不是在数据库中存储值,也不是显示任何php或mysql错误。
发布于 2018-05-29 09:41:22
insert-data.php:
$anno_x = (double) $_POST['anno_x'];
$anno_y = (double) $_POST['anno_y'];
$anno_width = (double) $_POST['anno_width'];
$anno_height = (double) $_POST['anno_height'];啊,真灵。
https://stackoverflow.com/questions/50342730
复制相似问题