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


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…

Lisa kommentaar »

Kommentaare veel pole.

RSS feed for comments on this post. TrackBack URI

Lisa kommentaar

Täida nõutavad väljad või kliki ikoonile, et sisse logida:

WordPress.com Logo

Sa kommenteerid kasutades oma WordPress.com kontot. Logi välja /  Muuda )

Google+ photo

Sa kommenteerid kasutades oma Google+ kontot. Logi välja /  Muuda )

Twitter picture

Sa kommenteerid kasutades oma Twitter kontot. Logi välja /  Muuda )

Facebook photo

Sa kommenteerid kasutades oma Facebook kontot. Logi välja /  Muuda )


Connecting to %s

Blog at WordPress.com.