Cross-frame dates cannot be serialised by Sys.Serialization.JavaScriptSerializer
Lets say you have a page with two iframes on it (frame A and frame B). In frame A we do this (forget why):
window.testDate = new Date();
and then in frame B we do this:
Sys.Serialization.JavaScriptSerializer.serialize(top.frames["frameA"].testDate);
We will get a stack overflow (in IE7 at least) when using the debug version of the Microsoft Ajax framework and we’ll just get nothing with the release version.
The root cause seems to be that in frame A testDate instanceof Date is true. But if we reference it from frame B it is false. This means that the serialiser does not correctly identify it as a date etc etc.
This is annoying if you are using the serialiser directly, but it is really annoying if you are forced to use it because you are using an MS Ajax script service proxy. I guess I will have to use jQuery to call the script service directly and take charge of serialisation myself using some other JSON library. I have seen it done but I just know it’s going to be painful…
PS – this issue is nicely described here
[...] instanceof scope problem Posted in Uncategorized by julianjelfs on January 15, 2010 In my previous post I explained how I ran into the problem that dateB defined on frameB would return false if you [...]
[...] part three Posted in Javascript by julianjelfs on January 24, 2010 So in my previous posts here and here I described a problem I was having with Microsoft Ajax script library serialisation of [...]