I am attempting to load chat messages with a javascript jQuery function using AJAX. I am new to jQuery and this is my first time using AJAX along with it. I call the function from my html with a script tag. My HTML source appears to be correct, but I get 404 not found error from my AJAX call. The URL the error returns adds some unfamiliar numbers to the end of it and I can't figure out why....
Here is my HTML
<script>
load_chat("http://localhost/basecommand/index.php/ajax/chat/conversations/2");
</script>
Here is my JS:
function load_chat(ajax_url) {
$.ajax({
type: "GET",
url: ajax_url,
dataType: "xml",
cache: false,
}
).done(
function(){
$("#chat_messages").fadeOut();
$(xml).find('message').each(function(){
$("#chat_messages").append(
'<div class="block1"><h1>' +
$(this).find("author_name").text() + '</h1><p>' +
$(this).find("content").text() + '</p><h3>About ' +
$(this).find("datesent").text() + ' ago.</h3></div>'
)
});
$("#chat_messages").fadeIn();
}
);
};
The error that is being returned: https://i.stack.imgur.com/jlobY.jpg
The URL works absolutely fine when I access it directly. No errors on the page, either.