-2

I have jQuery code with jQuery Mobile and when hitting a URL on another server, I see this error:

Syntax Error Invalid Label

The source is:

$(document).ready(function(){
    var location;
    var starPrice;
    var endPrice;
    var beds;
    var baths;
    var typep;

    $('#location').change(function(){
        typep = $("input[name='type']:checked").val();
        baths = $("input[name='baths']:checked").val(); 
        beds = $("input[name='beds']:checked").val();
        location = $('#location').val();
        starPrice = $('#priceStart').val();
        endPrice = $('#priceEnd').val();

        $.ajax({
            url: "/findListings",
            data:{
                limit: 10
            },
            dataType: "jsonp",
            type : 'POST',
        }).done(function(data) {
            alert(data[0].ListingId);
        });             
    });
});
p.campbell
  • 98,673
  • 67
  • 256
  • 322
  • You cant use $(document).ready(function(){ with jQuery Mobile. It will usually trigger before page DOM is ready. And if DOM is not ready you cant change it. Raed more about it here: http://stackoverflow.com/a/14469041/1848600 . Plus POST cant be used with jsonp, it must be GET. – Gajotres Mar 14 '13 at 14:09
  • I think its Syntax Error... There's nothing like Sintax.. :D – Ronnie Mar 14 '13 at 14:11

2 Answers2

2

Extra comma here

type : 'POST',
Brad M
  • 7,857
  • 1
  • 23
  • 40
0

some browsers will ignore some syantax errors.Here , is the problem

PSR
  • 39,804
  • 41
  • 111
  • 151
  • It's not a syntax error. The specification [quite clearly](http://www.ecma-international.org/ecma-262/5.1/#sec-11.1.5) allows a dangling comma in object initializers. – T.J. Crowder Mar 14 '13 at 14:32