Let me start by saying that I prefer not to use JQuery for any suggestions. I'm not a fan of how JQuery has become the de facto standard within JavaScript.
Now, onto my issue:
I want to pass a variable to a function that will then use that variable as the path to the file in a .open() method. Here's what I have so far:
An example of how the function is called:
ajaxPost('chatlog.txt',null);
The function itself:
function ajaxPost(targetPath, toSend){
var getMessage;
if (window.XMLHttpRequest){
getMessage = new XMLHttpRequest();
}
else{
getMessage = new ActiveXObject("Microsoft.XMLHTTP");
alert("Stop using Internet Explorer.");
}
getMessage.open("POST", targetPath, true);
getMessage.onreadystatechange = function(){
if (getMessage.readyState == 4 && getMessage.status == 200){
alert(getMessage.responseText);
}
};
getMessage.send(toSend);
}
Unfortunately, this doesn't seem to work for some unknown reason.