1

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?

2
  • 1
    class is a reserved word in ES5, you better use something else, e.g. className. Commented Nov 27, 2013 at 21:44
  • 1
    @Pavlo: It doesn't hurt but it's not an error. Any identifier is a valid property name in an object literal, which includes reserved keywords. Commented Nov 27, 2013 at 22:04

1 Answer 1

5

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' }
}; // <---
Sign up to request clarification or add additional context in comments.

1 Comment

Omitting the parenthesis should works as well (new AA.Aisis_Ajax(data_object, 'POST').init()) but readability suffers IMO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.