我在php中编写了插入程序。这是:
<?php
$conn = new mysqli('localhost', 'root', '','optimize_statusdb');
$email = $_POST['user_email'];
$m_id = $_POST['message_id'];
$t_id = $_POST['thread_id'];
$conn->query("INSERT INTO `trackid`(`user_email`, `message_id`, `thread_id`) VALUES ('$email',$m_id,$t_id)");
?>
这是我试图将数据发布到mysql的ajax函数:
View.on("sent", function(event) {
// If the user doesn't want the email to be tracked, we do nothing.
if (window.hunter_tracking_activated == true) {
$.ajax({
type: "POST",
url: "http://localhost:90/track/track.php",
data: {
thread_id: event.threadID,
message_id: event.messageID,
user_email: sdk.User.getEmailAddress(),
token: token
},
dataType: "JSON"
});
countUsage();
chrome.storage.sync.set({ "last_tracked_email_date": Date.now() });
alert("hello");
}
});
});
}
我正在尝试从data
的JSON中插入ajax code
字段的值。但是在运行程序之后,当我试图在表格中看到时,我看不到任何插入的值
那么,建议我如何使用我的代码实现这一目标。我如何通过Ajax将值插入我的mysql DB?