views:

30

answers:

1

I'm having a weird problem with jQuery and IE6. Script works on IE7+ and with all other browsers I have tried it.

I can't post the full script, but what it does is this:

$.post("file.php",{'foo':'bar'},function(data){ $('#target').append(data) })

When I run the code in IE6, #target just shows ? and a white char with a hole in the middle. I have no idea what this second char is.

My initial thought was that this was some sort of content-type problem because the file.php just echoes answer without any header information. I added Content-type: text/html with header() but didn't help.

Any suggestions?

+1  A: 

Very probably you see a character set issue.

Add a Content-Type header to your PHP response that correctly reflects both the type and the encoding your data is in.

header('Content-Type: text/html; charset=utf-8;') // for example
Tomalak
Didn't help. It's just weird that it's suppose to return "null" as a string right now but it just gives the ? and weird char.
Jim
@Jim: To make absolutely sure what's going on it's easiest to look at the data that *actually goes over the wire*. Please use a packet sniffer to track down the server response packet and check out the byte sequence in the HTTP message body. (Also: `utf-8` was just an example. Your data might be in a different encoding.)
Tomalak