2
我想要一個Chrome擴展程序,它將繼續將用戶訪問的URL插入到MySQL表中。使用Chrome擴展程序將使用Chrome訪問的URL插入到MySQL數據庫中
background.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>
insertdb.php
<?php
$val=$_REQUEST['url'];
// Inserting $val in the db code goes here.
?>
我是新來的JavaScript和這個代碼沒有按似乎工作。任何幫助將不勝感激。 非常感謝。
你嘗試移動'dataparam'和保存了URL函數內部的Ajax調用? – Chango 2013-02-08 17:57:55
是的,我試過這樣做,沒有運氣:( – contactsures 2013-02-08 18:26:36