我有一個XMLHttpRequest發送數據到PHP後端。訪問XMLHttpRequests在PHP後端發送(數據)
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
if (req.status == 200) {
// Resolve the promise with the response text
resolve(req.response);
}
else {
// Otherwise reject with the status text
// which will hopefully be a meaningful error
reject(Error(req.statusText));
}
};
// Handle network errors
req.onerror = function() {
reject(Error("Network Error"));
};
// Make the request
req.send('query=messages'); // <-- i want to access this in php
我想 print_r($_GET)
和print_r($_REQUEST)
但既不工程。
任何人都知道如何訪問這些數據?
你看了在瀏覽器的控制檯中的請求/響應? –
是@JayBlanchard它似乎並沒有在所有提供查詢=消息: GET /rest/api.php HTTP/1.1 主機:本地主機連接 :保持活躍 產地:HTTP://本地主機:8000 User-Agent:Mozilla/5.0(Windows NT 6.1; WOW64)AppleWebKit/537.36(KHTML,如Gecko)Chrome/47.0.2526.111 Safari/537.36 接受:*/* 引用者:http:// localhost:8000/index。 html Accept-Encoding:gzip,deflate,sdch Accept-Language:de-DE,de; q = 0.8,en-US; q = 0.6,en; q = 0.4 –
請參閱下面的答案。 –