简体   繁体   中英

Call REST service with JavaScript and parse results

I want a code for how to parse xml data, which is comming from restfull webservices. Please send code for how to call restfull webservices URL from javascript and this URL contains XML data. I want to read this xml data from javascript.

Thank U.

You can't grab data from another server using JavaScript, it's a security issue.

You can however create a server-side script which returns the XML required. Once you've done that, check out this very helpful article that walks through step by step of using jQuery to parse the XML

http://think2loud.com/224-reading-xml-with-jquery/

You can pass/get xml type through Jquery Ajax call. Two important things to be considered while passing the data as xml

  1. Specifying the datatype as "xml"
  2. Specifying the contentType as "text/xml; charset=\"utf-8\""

You can check out this article for calling your web service through java script and manipulating the data.

http://sharepoint-snippets.com/ajax-calls-sharepoint-web-services-using-jquery/

you can also check for various parameters used in Ajax call http://api.jquery.com/jQuery.ajax/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM