Within the workflow of an enterprise application, the following process takes place:
- Each service page features a "search box" where users can type something, triggering a call to a Struts 2 action through jQuery autocompleter.
- Upon the action call, Hibernate searches for clues based on the user's search in a MySQL database.
When clues are discovered, a JSON response is generated, similar to:
... "map": { "id": "1234", "title": "Title 1", "permalink": "title-1", "class": "contentClassA", "contentType": "Content type ..." }, ...
On the frontend JSP, JavaScript is used to create a list of
<div>
elements, each containing data from amap
object.
Steps 1-4 function correctly on Firefox versions up to 11 and Internet Explorer up to version 9. However, I encounter an issue when attempting to build a self.location
redirect in JavaScript to reload the page based on the value of class
. The problem arises when trying to retrieve the class
value from the JSON map
object using the following code:
var classType;
if(obj['class'] != undefined) {
classType = obj['class'];
} else {
//classType = obj.map.class;
//classType = obj['map'].class;
//classType = obj.class;
// ...
classType = obj.map['class'];
}
While this code works as expected in Firefox, Internet Explorer (versions 7-8-9) always falls into the else statement, resulting in the classType
variable being undefined regardless of the approach used.
Is there something I am overlooking?