Server unable to parse a valid json
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@gmail.com",
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',)
jquery ajax json
add a comment |
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@gmail.com",
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',)
jquery ajax json
Try encoding your data. If you see here: stackoverflow.com/questions/5263708/jquery-ajax-encoding-data, your contentType will require encoding
– diaho
Mar 15 '12 at 19:08
The server is expecting data in form of JSON, does it still require encoding? What is correct json MIME type anyway?
– Juzer Ali
Mar 15 '12 at 19:22
Try validating your JSON with jsonformatter.curiousconcept.com it is probably incorrect.
– bsimic
Mar 16 '12 at 0:19
add a comment |
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@gmail.com",
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',)
jquery ajax json
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@gmail.com",
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',)
jquery ajax json
jquery ajax json
edited Nov 13 '18 at 23:05
Juzer Ali
asked Mar 15 '12 at 19:01
Juzer AliJuzer Ali
2,7462254
2,7462254
Try encoding your data. If you see here: stackoverflow.com/questions/5263708/jquery-ajax-encoding-data, your contentType will require encoding
– diaho
Mar 15 '12 at 19:08
The server is expecting data in form of JSON, does it still require encoding? What is correct json MIME type anyway?
– Juzer Ali
Mar 15 '12 at 19:22
Try validating your JSON with jsonformatter.curiousconcept.com it is probably incorrect.
– bsimic
Mar 16 '12 at 0:19
add a comment |
Try encoding your data. If you see here: stackoverflow.com/questions/5263708/jquery-ajax-encoding-data, your contentType will require encoding
– diaho
Mar 15 '12 at 19:08
The server is expecting data in form of JSON, does it still require encoding? What is correct json MIME type anyway?
– Juzer Ali
Mar 15 '12 at 19:22
Try validating your JSON with jsonformatter.curiousconcept.com it is probably incorrect.
– bsimic
Mar 16 '12 at 0:19
Try encoding your data. If you see here: stackoverflow.com/questions/5263708/jquery-ajax-encoding-data, your contentType will require encoding
– diaho
Mar 15 '12 at 19:08
Try encoding your data. If you see here: stackoverflow.com/questions/5263708/jquery-ajax-encoding-data, your contentType will require encoding
– diaho
Mar 15 '12 at 19:08
The server is expecting data in form of JSON, does it still require encoding? What is correct json MIME type anyway?
– Juzer Ali
Mar 15 '12 at 19:22
The server is expecting data in form of JSON, does it still require encoding? What is correct json MIME type anyway?
– Juzer Ali
Mar 15 '12 at 19:22
Try validating your JSON with jsonformatter.curiousconcept.com it is probably incorrect.
– bsimic
Mar 16 '12 at 0:19
Try validating your JSON with jsonformatter.curiousconcept.com it is probably incorrect.
– bsimic
Mar 16 '12 at 0:19
add a comment |
1 Answer
1
active
oldest
votes
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@gmail.com",
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'
);
But why do I need to stringify it?? Doesn't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 4:23
Although what you suggested has worked, I wonder why do I need to stringify my JSON, can't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 6:21
1
nop jquery doesn't do it on its own, and the strange thing is that JQuery natively doesn't support converting data to JSON format, for that you have to use a plugin or native JSON object of browser
– Saket Patel
Mar 16 '12 at 7:25
1
3 years old but still as useful as today's. But its a shame that one has to do this manually after defining the content type
– Paullo
Jul 6 '15 at 9:36
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9726366%2fserver-unable-to-parse-a-valid-json%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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@gmail.com",
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'
);
But why do I need to stringify it?? Doesn't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 4:23
Although what you suggested has worked, I wonder why do I need to stringify my JSON, can't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 6:21
1
nop jquery doesn't do it on its own, and the strange thing is that JQuery natively doesn't support converting data to JSON format, for that you have to use a plugin or native JSON object of browser
– Saket Patel
Mar 16 '12 at 7:25
1
3 years old but still as useful as today's. But its a shame that one has to do this manually after defining the content type
– Paullo
Jul 6 '15 at 9:36
add a comment |
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@gmail.com",
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'
);
But why do I need to stringify it?? Doesn't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 4:23
Although what you suggested has worked, I wonder why do I need to stringify my JSON, can't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 6:21
1
nop jquery doesn't do it on its own, and the strange thing is that JQuery natively doesn't support converting data to JSON format, for that you have to use a plugin or native JSON object of browser
– Saket Patel
Mar 16 '12 at 7:25
1
3 years old but still as useful as today's. But its a shame that one has to do this manually after defining the content type
– Paullo
Jul 6 '15 at 9:36
add a comment |
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@gmail.com",
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'
);
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@gmail.com",
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'
);
edited Nov 13 '18 at 23:06
Juzer Ali
2,7462254
2,7462254
answered Mar 15 '12 at 21:30
Saket PatelSaket Patel
5,53011834
5,53011834
But why do I need to stringify it?? Doesn't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 4:23
Although what you suggested has worked, I wonder why do I need to stringify my JSON, can't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 6:21
1
nop jquery doesn't do it on its own, and the strange thing is that JQuery natively doesn't support converting data to JSON format, for that you have to use a plugin or native JSON object of browser
– Saket Patel
Mar 16 '12 at 7:25
1
3 years old but still as useful as today's. But its a shame that one has to do this manually after defining the content type
– Paullo
Jul 6 '15 at 9:36
add a comment |
But why do I need to stringify it?? Doesn't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 4:23
Although what you suggested has worked, I wonder why do I need to stringify my JSON, can't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 6:21
1
nop jquery doesn't do it on its own, and the strange thing is that JQuery natively doesn't support converting data to JSON format, for that you have to use a plugin or native JSON object of browser
– Saket Patel
Mar 16 '12 at 7:25
1
3 years old but still as useful as today's. But its a shame that one has to do this manually after defining the content type
– Paullo
Jul 6 '15 at 9:36
But why do I need to stringify it?? Doesn't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 4:23
But why do I need to stringify it?? Doesn't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 4:23
Although what you suggested has worked, I wonder why do I need to stringify my JSON, can't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 6:21
Although what you suggested has worked, I wonder why do I need to stringify my JSON, can't jQuery do it on its own?
– Juzer Ali
Mar 16 '12 at 6:21
1
1
nop jquery doesn't do it on its own, and the strange thing is that JQuery natively doesn't support converting data to JSON format, for that you have to use a plugin or native JSON object of browser
– Saket Patel
Mar 16 '12 at 7:25
nop jquery doesn't do it on its own, and the strange thing is that JQuery natively doesn't support converting data to JSON format, for that you have to use a plugin or native JSON object of browser
– Saket Patel
Mar 16 '12 at 7:25
1
1
3 years old but still as useful as today's. But its a shame that one has to do this manually after defining the content type
– Paullo
Jul 6 '15 at 9:36
3 years old but still as useful as today's. But its a shame that one has to do this manually after defining the content type
– Paullo
Jul 6 '15 at 9:36
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9726366%2fserver-unable-to-parse-a-valid-json%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try encoding your data. If you see here: stackoverflow.com/questions/5263708/jquery-ajax-encoding-data, your contentType will require encoding
– diaho
Mar 15 '12 at 19:08
The server is expecting data in form of JSON, does it still require encoding? What is correct json MIME type anyway?
– Juzer Ali
Mar 15 '12 at 19:22
Try validating your JSON with jsonformatter.curiousconcept.com it is probably incorrect.
– bsimic
Mar 16 '12 at 0:19