Firebug: "missing } after property list"

Posted on March 3, 2011 at 6:46 PM in General, jQuery

So I was doing some "quickie" JavaScript today, using jQuery, of course. I scribbled out some code. Then I decided to change the way I was going to handle it, so I commented out little bits and changed the code. I then decided to go back to my original idea, and uncommented everything that I had previously commented out. Or so I thought.

Run the code in the browser and Firebug puked all over it with the following error message in the console:

missing } after property list

Being the incredibly awesome, mistake-free programmer I am {insert raucous laughter here}, I glanced back at my code, knowing that I would not find a mistake. And, of course, I did not - all of the brackets were in place exactly as they should be. Run the test again. Same result. Clear browser cache. Run test again. Same result. WTF?

So back to the IDE we go. Let's look closer. Like line-by-line closer. And there it was. Not a missing bracket (as the error message indicated) at all. Instead, it was a missing comma (,) between options.

  1. $(".myformclass").ajaxForm({
  2. beforeSubmit:function(){
  3. }
  4. success:function(responseText,statusText,xhr,formObj){
  5. // stuff here
  6. }
  7. });

See it? Right there on Line 3.

So the next time you see "missing } after property list" in the error message from Firebug, be sure to check for commas, too! :-)

Oh, and by the way, if you have not yet been introduced to Mike Alsup's form plugin, be sure to check it out here. It is a very handy plugin.

Comments
(Comment Moderation is enabled. Your comment will not appear until approved.)

On 3/3/11 at 8:20 PM, Chris said:

I had something similar in my jquery valdation plugin.

I had an extra comma after my }

if (element.attr("name") == "membership") {
            error.appendTo("#membershipError");
         }
      } ,
   });

See that extra comma? It was killing all IE validation. But other browsers were lenient and dismissed the comma. I guess (gag me for saying this) this is a +1 for testing in IE 7/8. (that hurt to type).

On 3/3/11 at 9:28 PM, Matt Quackenbush said:

@ Chris - I almost banned your comment because of the IE praise! :-)

On 3/4/11 at 8:46 AM, Brian Swartzfager said:

Yeah, whenever I'm working with a jQuery plugin and I'm providing a list of plugin parameters, I'm very careful about those commas, because I've run into that error a few times myself.

And +1 regarding your recommendation of Alsup's form plugin. I don't use it quite as much anymore, but it's probably the most convenient way to submit a form via AJAX.

On 6/12/11 at 2:30 PM, Kazzador_ said:

Hey!! Thank You!! Brou!! This Article Helped me. I Had the same issue xD

On 6/22/11 at 4:16 AM, Nicolay said:

The same thing just happened to me, you gave me the idea to search for missing commas. Thanks, man :p

On 7/19/11 at 4:42 PM, yard said:

Same error appears when you dont surround the event with double quotes; thanks!

On 9/8/11 at 2:23 AM, Swatej said:

Hey Bro!! I had the same error and resolved it by seeing this expample. Thanks man!
CodeBassRadio

Latest Articles

Eventually something really brilliant and witty will appear right here.

Calendar

December 2023
S M T W T F S
« Nov  
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

Subscribe

Enter a valid email address.

The Obligatory Wish List