views:

62

answers:

1

This is driving me nuts ....

I have written a function

function seraliseQuery(){
for(var i=1; i<=variables;i++){
    alert(queryPreds[i]+" - "+queryObjs[i]);
  }
}

I just want to be able to call it from my other function

$(".object").click( function() {
    // code removed
seraliseQuery();
});

The error I get is "the function serialiseQuery() is undefined".

Everything is within

$(document).ready( function() { 
   // code goes here
}
+5  A: 

You just spelled it wrong. Rename the function "serialiseQuery".

Yeah, but it's spelled the same wrong in both places, so it should still be called.
Robert Harvey
Yep it was misspelled in both places. But when I spelled it correctly the method got called .... no idea. Thanks for your help.
Ankur
Since when is a British spelling "wrong"? (not sure if the OP is actually British though :) http://www.merriam-webster.com/dictionary/serialise
bmoeskau
@bmoeskau You're missing the point - OP wrote "seralise". And btw, British spelling had always been wrong in US and vice versa ;)
Amarghosh
Javascript has become self-aware and does not accept invalid literal names anymore. It throws a LanguageException.
Anurag
I assumed that he copied the code into StackOverflow incorrectly: look at how the error message is spelled.
lol, yes I should have read more closely... "seralise" is not correct in any language :)
bmoeskau
Totally OT, but that reminds me of a home-grown framework I used to have to work with that was authored by a dev with terrible spelling. His API's method names contained lots of misspellings, so it was horribly painful to have to write calls into the framework by misspelling words in my own code. Made it really hard to code without code completion too. Ah, memories...
bmoeskau