7

When I upgrade to jQuery 1.5.1 (or 1.5) all of the ajax() calls in my site produce a "parserror" in the error option function. There is also a script error

Uncaught SyntaxError: Unexpected token : jquery-1.5.1.min.js:16

The site has been running w/o errors using 1.4.4. Here is code from one of the ajax() calls.

$.ajax({
  url: '/CustomerGroup/Get',
  type: 'POST',
  contentType: 'application/json; charset=utf-8',
  dataType: 'json',
  success: function (grp) {
    if (grp != null) {
      clear();
      group = grp;
      load(grp);
    } else{
        showError(
                    'Customer Group',
                    'Whoops, error getting customer group information. Please contact support@myorg.com and include your username and date/time of the error.'
                    );
            }
  },
  error: function (x,s,e) {
    showError(
      'Customer Group',
      'Whoops, error getting customer group information. Please contact support@myorg.com and include your username and date/time of the error.'
      );
  }
});

After much research I can not figure out why the error is occurring. Any insights appreciated.

EDITED: With the full version of jQuery I get the following:

Uncaught SyntaxError: Unexpected token :
d.d.extend.globalEvaljquery-1.5.1.js:16
d.ajaxSetup.converters.text scriptjquery-1.5.1.js:16
bJjquery-1.5.1.js:16
wjquery-1.5.1.js:16
d.support.ajax.d.ajaxTransport.send.cjquery-1.5.1.js:16

and YES I am using jquery.validate.

Mandeep Jain
  • 2,304
  • 4
  • 22
  • 38
ChrisP
  • 9,796
  • 21
  • 77
  • 121
  • Try using the full not minified version of jQuery (jquery-1.5.1.js instead of jquery-1.5.1.min.js) and post the line number of the error. – rsp Mar 11 '11 at 18:25
  • Random question - are you also using jquery.validate with your code? I receive that exact error in this case. It works fine with 1.4.4. – JasCav Mar 11 '11 at 18:27
  • Unless you post the error message that you get while using the development (not minified) version of jQuery then we won't be able to even know which part of jQuery causes the problem, because in the minified version of jQuery basically everything is in line 16. – rsp Mar 11 '11 at 18:38

2 Answers2

8

This is a bug in the jQuery validation plugin. I hit the exact same problem two days ago. As it says on the jQuery validation plugin site, version 1.7 is not compatible with jQuery 1.5.x.

You need to install the newer version of validate from Jörn's github page.

Paul Schreiber
  • 12,531
  • 4
  • 41
  • 63
4

see http://bugs.jquery.com/ticket/8302

and try dataType: 'text json' in your code

agf
  • 171,228
  • 44
  • 289
  • 238
vasya
  • 41
  • 1