Ajax accesses the xml file code instance, and ajax accesses the xml instance

Source: Internet
Author: User

Ajax accesses the xml file code instance, and ajax accesses the xml instance

Ajax access to the xml file code instance:
Xml files are still frequently used. The following is an example code that uses jquery ajax to access xml files. It is very simple and I hope it can help my friends who need it, the code example is as follows:
I. ajax code:

 

$. Ajax ({url :'... ', type: 'post', ype: 'xml', error: function (xml) {alert ("Error loading xml document" + XML);}, success: function (xml) {$ (xml ). find ("X "). each (function (I) {alert ($ (this ). attr ("Xattr "));});}});

 

Ii. Background code:

Public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {response. setContentType ("text/xml; charset = UTF-8"); response. setCharacterEncoding ("UTF-8"); PrintWriter pw = response. getWriter (); Document doc = new Document (); // get the XML file doc. write (pw); return null ;}

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 10640.

For more information, see: http://www.softwhy.com/jquery/

 

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.