jQuery JSON response always triggers a ParseError -


i trying preform basic operations jquery , json. presently having difficulty jquery accepting json response play framework application. below simplified version of code still produces 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 triggered. displays

error... parsererror jquery15001997238997904205_1298484897373 not called

inspecting returned json through firebug shows no errors , various json lint tools validate. changing datatype "text" makes success called. trying use isusernameavailable call part of jquery validation plugin need return valid json.

maybe i'm misunderstanding, couldn't set datatype text , json.parse() returned data?

success: function(data) {     data = json.parse(data);     // process data }, 

edited add agreed upon solution (previously comment only):

i took @ api.jquery.com/jquery.ajax , looks jquery 1.5 can type conversion of sorts. "multiple, space-separated values: of jquery 1.5, jquery can convert datatype received in content-type header require. example, if want text response treated xml, use "text xml" datatype." maybe can try "text json".


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -