I have a page that resides within a frameset (this cannot be changed). The main page in frame 1 calls what is essentially a data loading page in frame 2. The page in frame 2 passes back a wddx object as a function parameter. Here is a very simple example:
Frame 2:
parent.content.newRoutes(newRouteList);
Frame 1 (named "content"):
function newRoutes(newRoutesContainerRouteRS) {
routesContainer.route_rs.appendRecordSet(newRoutesContainerRouteRS, false);
}
This works fine. However, later I load a new page into frame 2 to do some server side validation. After doing so, the next time I try to do anything with the routesContainer object I get the following error in IE8:
Can't execute code from a freed script
I understand why this occurs. The original page in frame 2 has been unloaded, so any references to objects or functions within it are no longer valid. I assumed that I could easily fix this problem by making a deep copy of the object passed back to frame 1 like this:
function newRoutes(newRoutesContainerRouteRS) {
// Deep copy
copiedContainer = jQuery.extend(true, {}, newRoutesContainerRouteRS);
routesContainer.route_rs.appendRecordSet(copiedContainer, false);
}
However, this still results in the same error message. Why doesn't this method solve the problem? Is jQuery.extend not creating a deep copy? I tried turning the copiedContainer variable into an array so that the previous object would not be wiped out each time this function is run, but that did not help.