Server unable to parse a valid json










10















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',)










share|improve this question
























  • 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















10















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',)










share|improve this question
























  • 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













10












10








10


3






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',)










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















19














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'
);





share|improve this answer

























  • 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










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
);



);













draft saved

draft discarded


















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









19














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'
);





share|improve this answer

























  • 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















19














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'
);





share|improve this answer

























  • 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













19












19








19







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'
);





share|improve this answer















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'
);






share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3