Is there a way to achieve serialization without calling the submit function for an ajax call? I've checked everywhere and can seem to find a decent answer for this particular problem. This is a java script function called when I click a button within the form.

```
document.forms[FORMNAME].submit();

```

Instead :

```
var form = $(document.forms[FORMNAME]);

$.ajax({
  type     : "POST",
  url      : form.attr('action'),
  data     : form.serializeArray(),
  success : function(data) {
    console.log("2");
  },
  error : function() {
    console.log("3");    
  },
  complete: function() {
    console.log("4");
  }
});

```

I get this error when I run.

```
Uncaught TypeError: form.attr is not a function

```

I also tried this.

```
var form = $(document.forms[FORMNAME]);

        $.ajax({
         type     : "POST",
         url      : $(form).attr('action'),
         data     : $(form).serialize(),
         success  : function(data) {
         console.log("2");
         },
         error    : function() {
         console.log("3");

         },
         complete : function() {
         console.log("4");
         }
        });

```

I really get my form when I do this `$(document.forms[FORMNAME])`.

Seems to only work when I work with this, but this is not what I want.

```
document.forms[FORMNAME].submit(function(event){

        // Stop form from submitting normally
        event.preventDefault();

        var $form = $(this);

        //AJAX STUFF
     });

```