我想有一个Chrome扩展,它将继续插入用户访问的url到MySQL表中。
背景.html
<script>
var myURL = "nourl";
chrome.tabs.getSelected(null, function(tab) {
myURL = tab.url;
});
dataparam = "url="+myURL;
$.ajax({
type: "POST",
url: "http://domainname.com/insertdb.php",
data: dataparam,
error:function() {
alert("sorry")
},
success: function(html) {
alert(html);
}
});
</script>
插入数据库.php
<?php
$val=$_REQUEST['url'];
// Inserting $val in the db code goes here.
?>
我是javascript新手,这段代码似乎不起作用。任何帮助都将不胜感激。
提前多谢了。
最佳答案
您需要获得跨源许可。
http://developer.chrome.com/extensions/xhr.html
关于javascript - 使用Chrome扩展程序将Chrome浏览器中访问的URL插入MySQL数据库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14778408/