0

I have a string like "£300 ON 110406" which I'm displaying to User. following is the Ajax which is getting fired to the spring controller which returns the data from DB:-

DB values are getting pushed through a separate Product , so can't change anything there.

$.ajax({ header:{ Accept:"*/*", "Mime-Type":"application/x-javascript;charset=iso-8859-15" }, type: "POST", cache: false, dataType:'json', url: ctx + "/url.htm", data: str, beforeSend: function(jqXHR) { if(jqXHR && jqXHR.overrideMimeType) { jqXHR.overrideMimeType('application/x-javascript;charset=iso-8859-15'); } },

previously above string was not coming fine on FIreFox and Chrome as well but after i added "beforeSend" method , now they are coming fine.

but IE still gives BOX characters.

Above Ajax code I have modified after googling most of the questions available for similar issue.

My page says below :-

<%@ page language="java" contentType="text/html; charset=iso-8859-15" pageEncoding="iso-8859-15"%> <% request.setCharacterEncoding("iso-8859-15"); %> <%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">

On my other page , I'm displaying same value but using Scriptlet so there no issues.

signature of my spring controller method:- If i add produces to this method , i get "cannot find presentation in browser console"

@SuppressWarnings("unchecked") @RequestMapping(value = "/url", method = RequestMethod.POST) private @ResponseBody String getFilteredData(

Jquery version is 1.11

I have been trying this in IE but it just don't work.. below is the screen shot from IE browser to show Accept and content-type.

If i change content type in Ajax then it does send data to the controller.

enter image description here

can you please let me know , how this can be resolved.

Rahul Razdan
  • 419
  • 4
  • 11
  • Why the use of the specific charset ISO-8859-15? Normally UTF-8 has the characters compatibility for most characters. – MiltoxBeyond Jun 25 '15 at 18:33
  • Yes , it does but £ is not getting supported. So unless i push mime type to be iso-8859-15 through beforesend method , it shows ? in all browsers. And in IE , even after doing that its boxes characters.. – Rahul Razdan Jun 25 '15 at 18:35
  • In that case you probably have stored the data in the database as UTF-8. That is trickier to convert to UTF-8. Check to be sure that the overrideMimeType is called in IE with a breakpoint. It doesn't seem to be the case by the looks of it. – MiltoxBeyond Jun 25 '15 at 18:44
  • Yes , i believe external product is stroing in iso-8859-15 , I placed a break point in IE java script and it executes overrideMimeType but does not make any effect .. as i read from many articles , IE does not support overrideMimeType – Rahul Razdan Jun 25 '15 at 18:46
  • Check to see if you have access to the underlying xmlhttprequest object, if so you can `setRequestHeader('Content-Type','YOUR CONTENT TYPE');` – MiltoxBeyond Jun 25 '15 at 18:49
  • i setted the content type :- beforeSend: function(jqXHR) { jqXHR.setRequestHeader('Content-Type','application/x-javascript;charset=iso-8859-15'); but no help , still box characters – Rahul Razdan Jun 25 '15 at 19:01

0 Answers0