My Problem: The json string returns as a file. When i call the getJSONResult action it will give me a file with the json string in it, which i can open or download.
I think it’s a configuration problem, but i can’t find it. I would be very glad if somebody could help me, thanks guys!
I have an opening form with a submit that uses an action and execute method to get the data. Then, the only way I could get jquery to work was to put an action and execute method that just returns ‘success’ and then I go onto my jquery grid with a 3rd action.
struts.xml
<struts>
<package name="live" namespace="/live" extends="struts-default,json-default">
<action name="gridAction" class="core.action.AdminAction">
<result name="success" type="json"></result>
<result name="error">/live/YYY.jsp</result>
</action>
</package>
</struts>
I assume you’re using Internet Explorer, because I’ve never gotten this problem with Google Chrome (and there’s even a plug-in that formats it all nicely and prettily: https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc)
Searching around, I’ve come up with two pages that offer the same solution to your problem, if indeed you are using IE:
View JSON in Internet Explorer
How can I convince IE to simply display application/json rather than offer to download it?
The main gist of the solution lies here:
Need to view JSON responses in IE?
Open Notepad and paste the following:
Note: This has been tested on Windows XP and Windows 7 using IE 7, 8, 9.