I use JQuery validation but somehow the Remote-validation can handle ØÆÅ-chars. It need to be charset= ISO-8859-1.
Can you see a way to handle this?
jQuery.validator.addMethod("customerExist", function(value, element, param) {
(...)
var data = {};
data["customer"] = value;
$.ajax($.extend(true, {
contentType: "application/json; charset=ISO-8859-1",
url: www+"validation.jsp",
mode: "abort",
dataType: "json",
data: data, //"{customer:'"+value+"'}",
success: function(response) {
alert("WORKS");
}
}, param));
return "pending";
}, "");
Example of the validation method I have made. Where can the error be for this charset problem?
I have tried this solution with out luck.
ContentType contentType:
"application/x-www-form-urlencoded; charset=UTF-8",
beforeSend
beforeSend: function(x){ x.overrideMimeType('application/json; charset=iso-8859-1'); },
The different pages: On HTML it is sat to:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
JSP page(that are called)
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-
=== MY SOLUTION ===
Use decode in Javascript:
data["customer"] = encodeURIComponent(value);
And use URLDecoder.decode in JSP-page
<%@page pageEncoding="ISO-8859-1" contentType="text/html; charset=ISO-8859-1" %>
<%@ java.net.URLDecoder" %>
<%
String customer = URLDecoder.decode(request.getParameter("customer"), "UTF-8");
%>