Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery $.get() charset of reply when no header is set?
    primarykey
    data
    text
    <p>I just recently installed <a href="http://www.oddsock.org/tools/gen_songrequester/" rel="noreferrer">Winamp Song Requester</a> wich is a Winamp web song requester plugin with a built in minimal HTTP CGI Server.</p> <p>What the plugin does is that it runs a web server, serves a html page with some special variables wich it replaces with actual data on request (playlist, request queue, time left in song etc).</p> <p>I saw this as a fun and good project to learn some jQuery so I started hooking up my own js code to replace, fix and ajaxify the served website from the plugin but I've now run into a problem with character encoding.</p> <p>On the page you get links to all songs in the playlist. When you click on one of the links I hooked up my own jQuery click function. So instead of reloading the whole page when you request a song I do a $.get($(this).attr('href', function(response) {... code ...}) and then I use replaceWith to replace the current queue with the new generated queue with your request added on the fly. I do the same thing to show/update currently playing and on search so that everything get fetched in the background and then replaced on the fly with some animations added.</p> <p>All jQuery/Ajax works great but the big problem I have is with charset and with song names in queue/playlist. Special characters (åäöé etc.) in names doesn't work at all.</p> <p>The plugin outputs everything in iso-8859-1/latin1 and my meta tag in the markup tells the browser that this page is latin1. On a normal page refresh in the browser this works well and the special characters display as normal. But when I use jQuery and $.get() to replace blocks of code on the fly the special characters only show up as ?.</p> <p>I think that the problem lies in that jQuery defaults to believe that the $.get() response is UTF-8 if no header says otherwise. The plugin doesn't set any header for encoding/charset at all and since I have no control at all of the backend and what headers get set I can't change this.</p> <p>The only headers I get in the response from the plugin is:</p> <blockquote> <p>Server: WinampServer<br/> Connection: close<br/> Content-Type: text/html</p> </blockquote> <p>I hope you understand my problem. I've got a page where I have no control at all over the backend and all I have to work with is generated HTML. I can't change or add headers in responses. I need to tell jQuery that the response is actually in latin1 and not UTF-8 so that the encoding of special characters don't break. I've tried the scriptCharset: 'iso-8859-1' in jQuerys ajaxSetup but that only works with type script/json and I'm working with HTML responses.</p> <p>Any idea if this is possible or any other workaround you could think about?</p>
    singulars
    1. This table or related slice is empty.
    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