• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing a json object from servlet

 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i am using a jquery library for form validation and no matter how i send the response I always get an ajax parse error.
According to the manual of the library i should send an array the exact words of the documentation is


Now my servlet sends this



I have also noted that in the ajax

Then the success callback of $.ajax is called other wise the error one is called.

Could anyone please tell me why i ma getting the parseerror here ??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64719
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not sending valid JSON. The "arr=" prefix and the trailing semicolon are not valid. You are sending a JavaScript statement rather than a JSON construct.
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also tried this and that didnt work as well. Any tips on how to get it rite??
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since that's identical to what you first tried, which didn't work, it's not surprising that it didn't work.

Have you considered taking Bear's points into account?
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just corrected a typo
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64719
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still seem to be under the assumption that JSON == JavaScript.

Not so.

Just because you can use single quotes to delimit a string in JavaScript, does not mean you can do the same in JSON.

Visit json.org. Learn it. Love it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic