I have this function within my <script> tags:

    var data = {
        title: "This is a title"

    Craft.postActionRequest('plugin/controller/action', data, function(response) {

The "Craft" function returns as "TypeError: Craft is undefined". I'm guessing I somehow need to reference the scope to the function but I can't seem to get it to work.

I tried adding _self = this outside my jquery click function and reference Craft like "_self.Craft" but that didn't do it.

What am I missing here?

  • 2
    Is this front-end or back-end? – Andris Sevcenko Oct 10 '14 at 13:07
  • It's for front-end use – naboovalley Oct 10 '14 at 13:12
  • Oh man I'm so retarded... ofc I can't use it on the front-end. Haha... Mystery solved. – naboovalley Oct 10 '14 at 13:13

The "Craft" javascript global object can only be used in the backend, not on the frontend.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.