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 
}
Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • 1
    Please share some code. That make sense.... – SASIKUMAR SENTHILNATHAN Jul 08 '15 at 08: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 } – Awais Aslam Jul 08 '15 at 09:22

2 Answers2

0

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

json_encode($your_html)
Ronald Zwiers
  • 780
  • 2
  • 10
  • 25
  • 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. – Awais Aslam Jul 08 '15 at 09:19
  • Maybe this answer could help you: [return-json-from-servlet](http://stackoverflow.com/questions/9645647/return-json-from-servlet) – Ronald Zwiers Jul 08 '15 at 09:46
0

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

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