首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将图像注释存储在数据库中,而不刷新页面

将图像注释存储在数据库中,而不刷新页面
EN

Stack Overflow用户
提问于 2018-05-15 05:12:21
回答 1查看 461关注 0票数 0

我希望将在图像上生成的注释存储在数据库中。我使用了声名狼藉的API来生成注释。API说:

有些版本与jQuery冲突臭名昭著。当在同一个页面上使用alias和jQuery时,您应该将jQuery置于无冲突模式,或者为jQuery的$别名分配一个新的变量名,或者将jQuery代码包装成一个函数,在这个函数中您可以在本地范围中使用$别名,

就像这样:

代码语言:javascript
复制
jQuery.noConflict();
jQuery(document).ready(function($) {
    // You can use the locally-scoped $ in here as an alias to jQuery.
    $('div').hide();
});

myAnnotations.php:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
<?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错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-29 09:41:22

insert-data.php:

代码语言:javascript
复制
$anno_x = (double) $_POST['anno_x'];
$anno_y = (double) $_POST['anno_y'];
$anno_width = (double) $_POST['anno_width'];
$anno_height = (double) $_POST['anno_height'];

啊,真灵。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50342730

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档