So I have a very simple ajax setup and it was working perfectly.
function ajax_post(){
var hr = new XMLHttpRequest();
var f = "foo";
var j = "bar";
hr.open("POST", "ajax7.php", true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var rd = hr.responseText;
}
}
hr.send("f="+f+"&j="+j);
}
Then I decided to slim it down by removing all the whitespace so I ended up with
function ajax_post(){var hr = new XMLHttpRequest();var f = "foo";var j = "bar";hr.open("POST", "ajax7.php", true);hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");hr.onreadystatechange = function(){if(hr.readyState == 4 && hr.status == 200){ var rd = hr.responseText;}}hr.send("f="+f+"&j="+j)}
And it stopped working, throwing an error. SyntaxError: missing ; before statement
So, I finally fixed it by adding a comma before hr.send in the one line version and it is working again.
My question...What is the significance of that comma? It works in the "expanded" version without it. Should I actually have been putting that comma in the "expanded" version all along...?