PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 2, 2022

[FIXED] JavaScript Error: "ReferenceError: array is not defined"

 February 02, 2022     arrays, cakephp, javascript, jquery     No comments   

Issue

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

ReferenceError: array is not defined

Here's 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 inside cakePHP view.


Solution

JavaScript is case sensitive, so to create a new array write Array with a capital letter:

var data = new Array();

However you may always use a short version:

var data = [];


Answered By - VisioN
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing