Hi all, another dumb question from a newbie - I am trying to pass an argument to a function to process server responses. My original line of code looked like this: "http.onreadystatechange = useHttpResponse;"
This works well enough as is, but I am trying to pass arguments to the function, and everything I am reading says to contruct the code like this: "http.onreadystatechange = fuction() {useHttpResponse(argument);};"
Every example I have come across uses this same approach, but I keep getting the error "Expected ';'" pointing to this line and then the code fails to execute. I just cannot see where there is anything missing, and it looks pretty much identical to my examples.
I have also tried replacing the call to the function with the actual code in long-form, and the result is the same. Any ideas?
There's nothing wrong with the code syntax the way you posted it. Removing the semicolon would not fix the problem, according to the way you quoted it. That code should work just fine. In fact, it would be more wrong to remove the semicolon. Perhaps you can paste more of your code so we can see the context?
thanks, yeah I thought it looked correct. Anyway here is the full function code:
Code:
function checkInput(filename, form, input)
{
var queryFile = filename + '.php';
var getInfo = 'checkuser';
var testdata = document.forms[form][input].value;
var url = queryFile + '?' + getInfo + '=' + testdata + '&rand=' + timeCode;
http.onreadystatechange = function() {useHttpResponse(form, input);};
http.open("GET", url, true);
http.send(null);
}
I have seen variations where "onreadystatechange" appears both before and after "open" and "send", but it doesn't seem to matter. I should note that I have tried palcing a semi-colon directly after "function()", and this does get rid of the error at the expense of rendering the function useless. Stumped.
Bookmarks