当我尝试通过 AJAX 将值发送到特定页面时,出现错误 - 404(未找到)
错误信息
GET http://localhost/titodiary/chat_message_send_data.php?user_logged_in_id=1&chat_with_friend_id=2&chat_message_input_text=ghost 404 (Not Found)
试过的代码
var user_logged_in_id = document.getElementById("user_logged_in_id").value;
var chat_with_friend_id = document.getElementById("chat_with_friend_id").value;
var chat_message_input_text = document.getElementById("chat_message_input_text").value.trim();
var chat_message_send_button = document.getElementById("chat_message_send_button");
var this_is_a_test_text = document.getElementById("this_is_a_test_text");
chat_message_send_button.onclick = ()=>{
// let's start Ajax
let xhr = new XMLHttpRequest(); // creating XML object
xhr.open("POST", "chat_message_send_data.php?user_logged_in_id=" + user_logged_in_id + "&chat_with_friend_id=" + chat_with_friend_id + "&chat_message_input_text=" + chat_message_input_text, true);
xhr.onload = ()=>{
if(xhr.readyState === XMLHttpRequest.DONE){
if (xhr.status === 200){
let data = xhr.response;
this_is_a_test_text.innerHTML = data;
}
}
}
xhr.send();
}
谁能找出问题所在?