403工具提示脚本中禁止的post错误

to94eoyn  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(126)

我一直在研究悬停的动态工具提示有一段时间了。
下面我提到了我的代码和工具提示脚本。

//html

<span data-id="1" class="info">Text</span>
<span data-id="2" class="info">Text</span>
...

//script

$(document).ready(function(){

  // Add tooltip
  $('.info').tooltip({
   delay: 3,
   placement: "bottom",
   title: userDetails,
   html: true
  }); 
  // Get user details for tooltip
function userDetails(){
  var userid = $(this).data('id');

  var tooltipText = '';
  $.ajax({
   url: 'ajaxfile.php',
   type: 'post',
   async: false,
   data: {userid:userid},
   success: function(response){
     tooltipText = response;
     $('.tooltip-content').html(response); 
   }
  });
  return tooltipText;
}
});

<script src="js/jquery-3.5.0.min.js"></script>

//php

<?php
include "include/db.php";

$userid = $_POST['userid'];

global $ConnectingDB;
$sql  = "SELECT * FROM tooltip_content WHERE id = '$userid'";  
$stmt =$ConnectingDB->query($sql);

$response = "";
while ($DataRows = $stmt->fetch()) {
    $id = $DataRows['id'];
    $Title = $DataRows["title"];
    $Description = $DataRows["description"];
    $response .= "<h4 class='tooltip-title'>".$Title."</h4>";
    $response .= "<div class='tooltip-body'>".$Description."</div>";

}

echo $response;
exit;

?>

这个代码有效。。但有时鼠标悬停时工具提示不会弹出,因为403禁止错误。
谁能告诉我我在代码中犯了什么错误?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题