JavaScript error: "ReferenceError: array not defined"

I want to make a JavaScript array and pass it to another page in php via email request. I get an error in firebug:

ReferenceError: array not defined

Here is the code:

 $(document).ready(function(){ var data = new array(); // this line throws the error // Handle Submiting form data $("#btnSumbit").click(function (){ $('#tblCriteria input[type=text]').each( function(){ data[this.id] = this.value; } ); 

This code is inside the cakePHP .

+4
source share
1 answer

JavaScript is case sensitive, so to create a new array, write an Array uppercase letter:

 var data = new Array(); 

However, you can always use the short version:

 var data = []; 
+13
source

All Articles