I am making this ajax request to a url, but server is sending a response 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 looks like this
$.ajax({url: "https://jsonparser.mydomain.com",
contentType: 'application/json',
type: "POST",
data :{name : "juzer ali",
email : "[email protected]",
how : "Used jQuery.ajax from google chromes developer console",
urls : ["https://chrome.google.com/webstore/search/", "https://chrome.google.com/webstore/detail/",
"https://github.com", "https://docs.google.com/document/d/edit?pli=1", "pro.appspot.com"]}
});
EDIT: Please notice Unrecognized token 'naejzraieale':
. the j
and r
in this error string is from the name property of the object I am passing in data. When I capitalize the letters, I get (Unrecognized token 'naeJZRAIeale': was expecting 'null', 'true',)
The parsing functions, parseArray() and parseObject() , may fail for 6 reasons: The input is not a valid JSON. The StaticJsonBuffer is too small. The StaticJsonBuffer is too big (stack overflow)
JSON parsing is the process of converting a JSON object in text format to a Javascript object that can be used inside a program. In Javascript, the standard way to do this is by using the method JSON. parse() , as the Javascript standard specifies.
before sending data to server you need to encode it in JSON format JSON.stringify and JSON.parse are provided by latest browsers but if any browser doesn't support that then you can use a jquery plugin to do the same http://code.google.com/p/jquery-json/, if you use this plugin then the syntax would be different a little bit
$.ajax({
url: "https://jsonparser.mydomain.com",
type: 'POST',
contentType:'application/json',
data: JSON.stringify({name : "juzer ali",
email : "[email protected]",
how : "Used jQuery.ajax from google chromes developer console",
urls : ["https://chrome.google.com/webstore/search/", "https://chrome.google.com/webstore/detail/",
"https://github.com/", "https://docs.google.com/document/d/edit?pli=1", "pro.appspot.com"]}),
dataType:'json'
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With