While sending ajax request getting error response

puneet kumar
puneet kumar used Ask the Experts™
on
Hi i am sending ajax request to java servlet on success ia m prining the response to servlet and sending back as ajax response
but after executing it gives error like below -

jquery-1.9.1.min.js:3 Uncaught TypeError: Cannot use 'in' operator to search for '72' in


{"Request Processed":"Request Processed"}
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Please show us the code that generated that error.
Thanx a ton for support julian.

Author

Commented:
thanx julian
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
@Puneet - you are always welcome but I am confused. You seem to have closed the question without an answer selecting your last post which is not an answer - was this intentional?

Author

Commented:
actually i solved this question with my self only.
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Then you should post your solution and accept it OR delete the question.

As it stands it looks like EE has a solution for this question but there is nothing in the thread to say how you solved it.

Author

Commented:
i set in me server side class one line like below -

 response.setContentType("application/json;charset=UTF-8");

it's work now .
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
If you are using jQuery to do your AJAX and you are receiving JSON back then you can get jQuery to do this automatically

$.ajax({
  url: 'script.jsp',
  data: {data: value},
  type: 'POST',
  dataType: 'JSON' // ADD THIS TO GET jQuery TO PARSE JSON RETURN
}).then(response) {
  // response is now a parsed JS Object
});

Open in new window

Or
$.post('script.jsp',{data: value}, function(response) {
}, 
'JSON' // ADD THE 4th PARAMETER TO GET jQuery TO PARSE JSON RETURN
)

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial