TheWebs
TheWebs

Reputation: 12933

object is not a function - Jquery/JavaScript

So the error message I am getting for:

(function($){
    var dataObject = {
        class : 'someClass',
        method : 'someClassMethod',
        data : { someData : 'example' }
    }

    (new AA.Aisis_Ajax(data_object, 'POST')).init();

})(jQuery)

pertains to:

    var dataObject = {
        class : 'someClass',
        method : 'someClassMethod',
        data : { someData : 'example' }
    }

(If that's deleted the code works...)

The issue is that this returns object is not a function. well duh, I am trying to create a object that's passed to the class Aisis_Ajax

What is going on here?

Upvotes: 1

Views: 56

Answers (1)

p.s.w.g
p.s.w.g

Reputation: 149078

The problem is that your object declaration is immediately followed by parenthesis, so the parser thinks you're trying to call a function.

Try putting a semicolon at the end of your object declaration:

var dataObject = {
    class : 'someClass',
    method : 'someClassMethod',
    data : { someData : 'example' }
}; // <---

Upvotes: 5

Related Questions