No callback function is executed and no error is reported if the data returned by the ajax request is invisible.

Source: Internet
Author: User

The project uses ssh and $. post of jquery to access struts2's Action. No error is reported, but no result is returned.

Now $. post returns a Collection containing the permissions <Privilege>. The permission Class Privilege is associated with the User class, that is, the set Set set in Privilege stores the User Set <User> with this permission, and the set Set set in User also saves the User's permission Set <Privilege>. The data is in the action, but the callback function is not executed and the returned data is not displayed during browser debugging. The reason is as follows:

When jquery parses the returned Collection <Privilege> Set, it will see a Set <User> in it to get the data in the Collection, however, Collection <Privilege> is returned by a method in the service. At this time, the spring transaction has ended and no data is found in Set <User>. An error occurs when jquery parses an empty set, so no data is available.

Solution: add this annotation @ JSON (serialize = false) to the getUser () method in Privilege, so that jquery will ignore the data in this set during parsing. Of course, if you want to use the data, you need to first check the data in the service and put it in the collection.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.