我想创建一个Chrome扩展程序,点击它后,获取当前标签的URL并将其传递给我的MySQL表格。这是我到目前为止所处的位置:
Manifest.json
{
"name": "Markr",
"version": "1.0.10",
"manifest_version": 2,
"description": "The ultimate bookmarking tool",
"icons": { "32": "icon.png" },
"default_icon": "icon.png",
"default_popup": "bookmark.html"
},
"permissions": [
"tabs",
"http://*/*"],
"offline_enabled": false
}
bookmark.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script_v3.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
</head>
<body>
<h1>This site has been bookmarked.</h1>
</body>
</html>
script_v3.js
$(document).ready(function(){
var taburl;
chrome.tabs.query({
active: true,
lastFocusedWindow: true
}, function(array_of_Tabs){
var tab = array_of_Tabs[0];
taburl = tab.url;
});
$.ajax({
url: "http://localhost/markit/site/base.php",
type: "POST", //default is GET
data: {
var taburl: url;
}
crossDomain:true,
cache:false,
async:false,
});
});
base.php
<?php
$url = $_REQUEST["url"];
mysql_connect("localhost", "root", "") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("bookmarks") or die(mysql_error());
echo "Connected to Database";
mysql_query($write = "INSERT INTO links (url) VALUES ($url)");
?>
为什么不起作用?