I have a very annoying problem With my Jquery based ajax live search. The search itself is working, but whenever my querystring contains ‘ő’ and ‘ű’ – only these two chars – , the value of the req.getParameter(“sstring”) is null! If the querystring does not have the mentioned chars, it returns the value successfully.
I tried all possible encodings inluding UTF-8 but settled using 8859-2.
$.ajax({
type:"GET",
url: "/myApp/Protected/getStd",
contentType: "application/x-www-form-urlencoded; charset=iso-8859-2",
dataType:"application/x-www-form-urlencoded; charset=iso-8859-2",
data:"sstring="+escape(sstring)+"&options="+id+"&startrow="+startrow+"&valid="+Valid+"¬Valid="+notValid+"&searchForm=1",
async: true,
success: function(data){
$("#external").html(data);
}
})
I have to highlight that the problem only occures when the querystring is passed by Jquery. If I enter the QueryString to the browser manually the Servlet gets it properly.
Any help is much appreciated.
As per the comments on the question:
The
sstringparameter is not properly URL-encoded. You needencodeURIComponent()instead ofescape().