News for January 2011

jQuery Error ‘expected identifier, string or number’ in IE7

While working on a site today, I came across an issue where some of my jQuery code was not functioning properly. The code in question was working properly in all the browsers sans IE7. (FireFox, IE8, Chrome, Safari on both mac and PC)

Having to debug it as soon as possible, as it was on a live site, I came across a solution. Take a look at the code in question (small snippet) that was throwing the error.

function performShippingQuote(addr, zipcode, province) {
    if (addr == last_addr && zipcode == last_zip) return;
    last_addr = addr;
    last_zip = zipcode;
    
    $.ajax({
      type: 'GET',
      url: Drupal.settings.basePath,
    success: updateShippingCost,
       dataType: 'json',
      data: {
         q:'addresses/shipping_ajax',
         program:$j('input#edit-program-program-nid').val(),
         address:addr,
         zip:zipcode,
         state:province,
       }
     });
}
  

If you notice on line:16 there is an ‘,’ at the end. This trailing comma was the culprit! Upon removing it presto everything worked like a charm across all browsers!

Posted: January 15th, 2011
Categories: code
Tags: , ,
Comments: No Comments.