0

When I try to send HTML content in JSON object as a response from servlet, then IE 10 does not receive HTML content with tags. Response type is application/json

Java:

String summaryRptHTML = sum.generateSummaryTable(summary, false);
jSonObj.put("hasError", false); 
jSonObj.put("message", "File Proceesed"); 
jSonObj.put("summary", summaryRptHTML ); 

JavaScript :

Client: "ProcessFileServlet", 
function(responseJSON) { 
  System.hideLoadingScreen(""); 
  responseJSON = eval(responseJSON); 
  responseJSON.summary; // its nothing 
}
2
  • 1
    Please share some code. That make sense.... Commented Jul 8, 2015 at 8:54
  • String summaryRptHTML = sum.generateSummaryTable(summary, false); jSonObj.put("hasError", false); jSonObj.put("message", "File Proceesed"); jSonObj.put("summary", summaryRptHTML ); Client: "ProcessFileServlet", function(responseJSON) { System.hideLoadingScreen(""); responseJSON = eval(responseJSON); responseJSON.summary; // its nothing } Commented Jul 8, 2015 at 9:22

2 Answers 2

0

Do you json_encode your html you are sending and using a JSON decoder on the Java side?

json_encode($your_html)
Sign up to request clarification or add additional context in comments.

2 Comments

Hello Ronal, same code is working for FF, chrome and Opera but I.E is generation apart from these browsers. when i set response type to text/html then IE fetch html data without html tags. and when i set response type to application/json then IE do not get any HTML content.
Maybe this answer could help you: return-json-from-servlet
0

Problem Solved! :) Server Side: use resonse type text/plain

Client Side: Use EVAL() function on jsonobj responseJSON = EVAL(responseJSON);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.