Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery: Set encoding for json response to utf8
    primarykey
    data
    text
    <p>I'm getting my response for jQuery in json. The logic works fine, but I can't get him to proper encode the data (like üäö).</p> <p>I've searched and found <a href="https://stackoverflow.com/questions/26620/how-to-set-encoding-in-getjson-jquery">this</a> question on SO, which suggested to change the <code>getJSON</code> to a normal AJAX call. I've done that, and added the <code>setContentType</code> option, but still, I'm getting weird signs, as soon as an äüö appears.</p> <p>Any ideas on how to solve that?</p> <pre><code>$(function() { $("#cnAntragsteller").autocomplete({ source: function(request, response) { $.ajax({ url: "http://localhost/api", dataType: "jsonp", data: { search: request.term }, success: function(data) { response($.map(data.persons, function(item) { return { label: item.cn + " (PN: " + item.imPersonalNumber + ")", value: item.cn, pn: item.imPersonalNumber, cn: item.cn, cc: item.imCostCenter, jb: item.imJobTitle, jbd: item.imJobTitleDescription } })); } }); }, minLength: 0, select: function(event, ui) { $("#pnAntragsteller").val(ui.item.pn); $("#jbAntragsteller").val(ui.item.jb); $("#jbdAntragsteller").val(ui.item.jbd); $("#ouKostenstelle").val(ui.item.cc); $.ajax({ url: "http://localhost/api", contentType: "application/json; charset=utf-8", dataType: 'json', data: { pn: ui.item.pn }, success: function(data) { $("#cnLeiter").val(data.cn); } }); } }) }) </code></pre> <p>Response Headers (first Header doesn't display data, it just redirects to the output):</p> <pre><code>Content-Length:0 Date:Tue, 22 May 2012 06:13:41 GMT Location:http://localhost/api/redirection Server:Apache-Coyote/1.1 Content-Length:177 Content-Type:text/html Date:Tue, 22 May 2012 06:13:41 GMT Expires:0 Server:Apache-Coyote/1.1 </code></pre> <p>Note: These are only the response headers, do the request headers also contain important information?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload