c# - During request ,the parameter encoded in strange manner -
sometimes face following problem :
string txt = con.request.params["par_name"].tostring();//the original par value arabic text
i following result!!
��� ������ ������� �����
what's reason problem , how original arabic text ??
when send string via url parametres, via ajax , utf-8 avoid conflicts must encode javascript functions encodeuricomponent
. encode part of value, not parameters , full url ! when read parameters on code behind urldecode default, if not, manually.
for example code https://stackoverflow.com/a/10968848/159270 be:
jquery.ajax({ url: "/logaction.ashx?par_name=" + encodeuricomponent(par_name) + "&par_address=" + encodeuricomponent(par_address), type: "get", timeout: 3000, async: true, // can try , async:false - maybe better data: action=4, // here send log informations cache: false, success: function(html) { jquery("#formid").submit(); }, error: function(responsetext, textstatus, xmlhttprequest) { jquery("#formid").submit(); } });
i did not include encode on previous answer because not send string parameters, variables, , because answer not focus on detail.
you can read : http://xkr.us/articles/javascript/encode-compare/
Comments
Post a Comment