The data returned by the AJAX request does not see the callback function is not executed or the error _ajax related

Source: Internet
Author: User
Tags set set
The project is SSH, using jquery's $.post to access Struts2 's action, where there is no error, but no results.

Now $.post is going to return the collection Collection<privilege> that holds the permission, and the permission class privilege is associated with the user class user, which means that the set set is saved by the privilege with the permission <user>, users also use the Set collection to hold the user's permissions set<privilege>. The data went to the action, but the callback function was not executed, and the data returned was not seen using browser debugging, and it was finally found for a long time, for the following reasons:

When jquery parses the returned collection<privilege> collection, it sees a set<user> inside it, and then it gets the data in the collection, but collection<privilege> is returned by a method in the service, and this time spring's transaction is over, and the data in the set<user> is not found. jquery resolves an empty collection and then fails, so no data is available.

Workaround: The GetUser () method in privilege adds this annotation @json (serialize=false) so that jquery ignores the data in the collection when parsing it. Of course, if the data is to be used, it is necessary to 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.