Using an inline callback function

Using an inline callback function

Having a really hard time getting this to work, could use a little guidance on what I'm doing wrong....the code should be fairly self explanatory....

  1. function callbackTest(file, callback)
  2. {
  3.       $.get
  4.       (
  5.             file,
  6.             function(data)
  7.             {
  8.                   // do something
  9.                   callback.call(data);
  10.             }
  11.       );
  12. }

Then call it like.....
  1. $(document).ready
  2. (
  3.       function()
  4.       {
  5.             callbackTest
  6.             (
  7.                   "file.html",
  8.                   function(data)
  9.                   {
  10.                         alert(data);
  11.                   }
  12.             );
  13.       }
  14. );
When I try this, I get an error from the callbackTest function, "callback is not a function".

Obviously this isn't the correct way to do what I want (or it would work!), but it should be pretty clear from this exactly what I'm trying to achieve. Any help at all would be appreciated.

Cheers.