jQuery JSON response always triggers a ParseError

I am trying to preform some basic operations with jQuery and JSON. Presently having difficulty with jQuery accepting JSON response from my play framework application. Below is a simplified version of the code that still produces the error.

$.ajax({
    type: 'POST',
    url: "@{FrontEnd.isUsernameAvailable()}",
    data: "name=thisnameisavailable",
    cache: false,
    success: function(data) {
        console.log("Success... ");
    },
    error: function(jqXHR, textStatus, errorThrown) {
        console.log("Error... " + textStatus + "        " + errorThrown);
    },
    dataType: 'json'
});

The error callback is always triggered. It displays

Error... parsererror jQuery15001997238997904205_1298484897373 was not called

Inspecting the returned JSON through Firebug shows no errors and various JSON lint tools also validate. Changing dataType to "text" makes success be called. But I am trying to use the isUsernameAvailable call as part of jQuery validation plugin so I need it to return valid JSON.

34
задан Chesrae 23 February 2011 в 18:27
поделиться