php代码
<?php
header("Content-type:text/html;charset=UTF-8");
$data=json_decode($_POST['data']);
$repon=array("成功");
$json=urldecode(json_encode($repon));
echo $json;
?>
前段js代码
// 监听来自content-script的消息
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse){
console.log("收到来自content-script的消息:");
pageinfo=request.msg;
console.log(request.msg);
var rep=$.ajax({
type:"post",
url:"http://127.0.0.1/mysqlhelper.php",
dateType:"json",
async:true,
date:{date:pageinfo},
error: function(request) {
console.log("Connection error");
},
success: function(repon) {
console.log(JSON.stringify(repon));
}
});
});