TryHarder
TryHarder

Reputation: 2777

What is wrong with this code? error "missing } after property list"

Can someone tell me what is wrong with this jquery?

function() {  
var testscore =100; //testvalue to enter into the mysql database
$.ajax({  
                type: "POST",  
                url: "ajax.php",  
                data: testscore,  
                success: function(){  
                $('#hiddendiv').fadeIn();};  

            })
            }; 

I keep getting the following error

missing } after property list
[Break On This Error] $('#hiddendiv').fadeIn();}; 

Upvotes: 0

Views: 310

Answers (1)

Gazler
Gazler

Reputation: 84180

The semi-colon at the end of the following line is what is breaking the code:

$('#hiddendiv').fadeIn();};

You are inside an object literal, so you delimit the property values with a comma and not a semi-colon.

You may be able to spot such issues more easily if you format your code properly:

function() {  
  var testscore =100; //testvalue to enter into the mysql database
  $.ajax({  
    type: "POST",  
    url: "ajax.php",  
    data: testscore,  
    success: function(){  
      $('#hiddendiv').fadeIn();
    } 
  });
}; 

Upvotes: 3

Related Questions