0

We use an XMLHttpRequest mock up object to test our ExtJs 4.1 app with Jasmine. Now, everythings works perfectly in Chrome and Firefox, but IE versions 7 till 9 are making trouble as always.

There is an error at onreadystatechange function,

if readyState is 1 then SCRIPT575 (cannot continue due to error c00c023f)

if readyState is 2 then SCRIPT10 (required data not yet available)

See this Jsfiddle (search for "error" to jump to line)

Additionally, there is a error TypeError: Object expected.


What I have read:

I read a couple of posts like this and that, but none of the recommendations fixed it.


Note:

in Chrome & Firefox all requests only return readyState 4, but in IE readyState the values are repeated from 1 till 4 (?).

Chrome & FF
readyState 4 => OK
readyState 4 => OK
readyState 4 => OK
readyState 4 => OK
readyState 4 => OK
...

IE:
readyState 1 => error
readyState 2 => error
readyState 3 => OK
readyState 4 => OK
readyState 1 => error
...

Can you guide me how to fix this? I have no clue.

Community
  • 1
  • 1
Shlomo
  • 3,880
  • 8
  • 50
  • 82

2 Answers2

1

Check the readyState value before reading responseXML/responseText properties. If readyState value is 4, you can safely access responseXML/responseText

(The original implementation and later specification of XMLHttpRequest required implementations to throw exception on access to data before object has completed I/O operation)

Sergey Ilinsky
  • 31,255
  • 9
  • 54
  • 56
  • Thanks for the answer. When I check with `if( oXhr.readyState > 3 )` these errors are gone.But still, why are there 1-4 readystates in IE. Now, another error comes up `object expected` in ExtJs. I will check that and get back. – Shlomo Dec 07 '12 at 11:28
  • There is chance you are running sync requests, these may not trigger all readyState changes in other than IE9- browsers. – Sergey Ilinsky Dec 07 '12 at 13:22
  • Yes I use `Ext.syncRequire` but also tried `Ext.require`. No difference. – Shlomo Dec 10 '12 at 08:15
-1

There was a property named response that should be responseText.

Also, I am checking readyState with if( typeof oXhr.readyState !== 'undefined' ) {}

Now my code works in IE8, IE9 (Standard).

However, IE8, IE9 (Quirks) and IE 7 (Quirks & Standard) fail with error:

SCRIPT16389: Unknown error

I will try to fix, but this question is done.

Shlomo
  • 3,880
  • 8
  • 50
  • 82