DrupalSouth 2010

Doing my bit

User login

s.success is not a function

This post is about JavaScript, jQuery and annoying errors that don't seem to have a solution out there. Right, keywords done. Here's the problem and the solution I used;

I was having an issue with a jQuery call that was returning the following error;

s.success is not a function

The code that was generating this was the callback function on the successful return from a getJSON() call. This is the original script;

call = '/admin/ts2/pending/approve/'+sid+'/'+c1+'/'+c2+'/'+c3;
$.getJSON(call, '', 'process_approved');

After a decent amount of hunting I drew a blank. There's a reasonable number of queries about this but no answer that I could use. One was a patch on the original jQuery source but given I'm working in a framework I'm not able to touch that.

I eventually figured out a work around though. Instead of using a callback function I used an in-line function and from that called my external function. This is the code as it stands now;

call = '/admin/ts2/pending/approve/'+sid+'/'+c1+'/'+c2+'/'+c3;
$.getJSON(call, '', function(data)
  {
    process_approved(data);
  }
);

Hopefully this will be of use to someone.

JavaScript, despite the

JavaScript, despite the name, is essentially unrelated to the Java programming language even though the two do have superficial similarities. Both languages use syntaxes influenced by that of wedding gowns C syntax, and JavaScript copies many Java names and naming conventions.