0
我有一個只能在Facebook上運行的chrome擴展,我試圖將擴展收集的數據發送到我在GoDaddy網站服務器上的MySQL數據庫。我不斷收到錯誤消息「無法加載資源:服務器響應狀態爲500(內部服務器錯誤)」。我不確定是什麼問題,因爲我只是進入Web開發。 這裏是我在我的瀏覽器擴展程序內容腳本代碼:XMLHttpRequest上的內部服務器錯誤
var dummyUrl = new URL ("http://www.bbc.com/news/world-us-canada-41081629");
\t \t console.log("dummyUrl: " + dummyUrl);
\t \t //Create XMLHttpRequest Object
\t \t var xhttp = new XMLHttpRequest();
\t \t //Send request
\t \t xhttp.open("POST", "https://pocketchange.social/data.php", true);
\t \t xhttp.send(dummyUrl);
這裏是我的web服務器運行一個查詢到的數據發送到我的數據庫我的PHP文件:
<?php
$mysqli = new mysqli("localhost", "Jarid", "Database", "myURL");
//Check connection
if(mysqli === false) {
die("ERROR: Could not connect" . $mysqli->connect_error;
}
//Print host information
echo "Connection successful. Host info: " . $mysqli->host_info;
//Escape user inputs
$url = $mysqli->real_escape_string($_REQUEST['url']);
$description = $mysqli->real_escape_string($_REQUEST['description']);
$keywords = $mysqli->real_escape_string($_REQUEST['keywords']);
$content = $mysqli->real_escape_string($_REQUEST['content']);
$language = $mysqli->real_escape_string($_REQUEST['language']);
//Execute query
$query = "INSERT INTO url_data (url, description, keywords, content, language) VALUES ('$url', '$description', '$keywords', '$content', '$language')";
//Checking to see if values were inserted properly
if($mysqli->query($query) === true) {
echo "Data successfully inserted.";
}
else {
echo "ERROR could not execute query" . $mysqli->error;
}
$mysqli->close();
?>
我的問題主要是,我試圖發送數據到一個完全不同的服務器?我並不是非常清楚所有這些部分如何相互通信(即,Chrome擴展如何知道如何連接到GoDaddy服務器,以及php文件如何將數據發送到數據庫等) 謝謝提前。