Server cannot parse valid json

I make this ajax request to the url, but the server sends an Unrecognized token 'naejzraieale': was expecting 'null', 'true', 'false' or NaN at [Source: org.eclipse.jetty.server.HttpInput@13367e3; line: 1, column: 25] response Unrecognized token 'naejzraieale': was expecting 'null', 'true', 'false' or NaN at [Source: org.eclipse.jetty.server.HttpInput@13367e3; line: 1, column: 25] Unrecognized token 'naejzraieale': was expecting 'null', 'true', 'false' or NaN at [Source: org.eclipse.jetty.server.HttpInput@13367e3; line: 1, column: 25] .

My Ajax request is as follows

 $.ajax({url: "https://jsonparser.mydomain.com", contentType: 'application/json', type: "POST", data :{name : "juzer ali", email : "er.juzerali@gmail.com", how : "Used jQuery.ajax from google chromes developer console", urls : ["https://chrome.google.com/webstore/search/passportpro", "https://chrome.google.com/webstore/detail/ffimgldnoigmlcofmfkfcjechbdkipph", "https://github.com/juzerali", "https://docs.google.com/document/d/1BXOwXojdKwghZ3nvnfPeleEgjv0whJVWVXtQMwcXLiA/edit?pli=1", "authagentpro.appspot.com"]} }); 

EDIT: Pay attention to Unrecognized token 'naejzraieale': j and r in this error line from the name property of the object that I pass in the data. When I use letters, I get (Unrecognized token 'naeJZRAIeale': was expecting 'null', 'true',)

+8
json jquery ajax
source share
1 answer

Before sending data to the server, you need to encode it in JSON format JSON.stringify and JSON.parse are provided by the latest browsers, but if any browser does not support this, you can use the jquery plugin to execute the same http://code.google. com / p / jquery-json / , if you use this plugin then the syntax will be slightly different

 $.ajax({ url: "https://jsonparser.mydomain.com", type: 'POST', contentType:'application/json', data: JSON.stringify({name : "juzer ali", email : "er.juzerali@gmail.com", how : "Used jQuery.ajax from google chromes developer console", urls : ["https://chrome.google.com/webstore/search/passportpro", "https://chrome.google.com/webstore/detail/ffimgldnoigmlcofmfkfcjechbdkipph", "https://github.com/juzerali", "https://docs.google.com/document/d/1BXOwXojdKwghZ3nvnfPeleEgjv0whJVWVXtQMwcXLiA/edit?pli=1", "authagentpro.appspot.com"]}), dataType:'json' }); 
+17
source share

All Articles