…meie igapäevast IT’d anna meile igapäev…

2009-11-13

Headers in JavaScript: Firefox vs others

Problem with a JS-heavy web application. Administrators have some extra controls, which should be visible if server sends “seeall” header with a value “True” (don’t worry, the actual check about using those controls is on server-side, this is just for visibility). It works fine in Firefox, but fails completely in IE and Chrome.

Everything looks completely legit in other browsers. The header exists and has the value “True”… but the comparison still fails.

In the end I found the issue – it seems that Chrome and IE do not strip \r (carriage return) control symbol from the header value string. This can be illustrated with the following pseudocode:

if (data.getResponseHeader['seeall'] == 'True') alert("True in Firefox");

if (data.getResponseHeader['seeall'] == 'True\r') alert("True in non-Firefox");
 
The quick’n’dirty solution? Compare just first four symbols…
About these ads

Lisa kommentaar »

Kommentaare veel pole.

Selle postituse kommentaaride RSS-voog. TrackBack URI

Lisa kommentaar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Muuda )

Twitter picture

You are commenting using your Twitter account. Log Out / Muuda )

Facebook photo

You are commenting using your Facebook account. Log Out / Muuda )

Google+ photo

You are commenting using your Google+ account. Log Out / Muuda )

Connecting to %s

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 81 other followers