Results 1 to 4 of 4

Thread: onreadystatechange expecting ';'

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Birmingham, UK

    onreadystatechange expecting ';'

    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?

  2. #2
    Join Date
    Apr 2010
    note sure but if this is your exact code, 2 things

    "http.onreadystatechange = fuction() {useHttpResponse(argument);};"
    shoudl be

    "http.onreadystatechange = function() {useHttpResponse(argument)};"

  3. #3
    Join Date
    Dec 2008
    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?

  4. #4
    Join Date
    Jul 2010
    Birmingham, UK
    thanks, yeah I thought it looked correct. Anyway here is the full function 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);
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center