i want to insert data to server using ajax in my chrome extension so my users can sign up to use my extension. i am desperately finding solution not not find the example
when i code ajax on popup.html i got this error "Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-lXzxt12nj+7ATE1j5ucGnYo1VkLZpNS/cGA9SL9nCv0='), or a nonce ('nonce-...') is required to enable inline execution."
popup.html Code
<!DOCTYPE html>
<html>
<head>
<style>
body {
width:300px;
font-size:12px;
}
</style>
</head>
<body>
<form action="" method="POST">
<input type="text" id="name" name="uname">
<input type="text" id="pass" name="upass">
<input type="submit" id="submit" name="submit" id="btn">
</form>
</body>
</html>
<script type="text/javascript" src="check.js"></script>
<script type="text/javascript">
$("#btn").click(function(){
var btn =$('#btn').val();
var name= $('#name').val();
var pas = $('#pass').val();
$.ajax({
data :{btn: btn, name : name, pas: pas},
method="POST",
url:"http://localhost/status/index.php",
success : function(data){
lb.val(data);
}
});
});
}
</script>
index.php code which is on server
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if(isset($_POST['byn'])){
$localIP = getHostByName(getHostName());
$name = $_POST['name'];
$pass = $_POST['pass'];
$insert = mysqli_query($conn,"INSERT INTO usercheck VALUES('','$name','$pass','1111,'$localIP')");
}
?>