How to use restfull webservices with jquery [closed]
We do开发者_如何学JAVAn’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this questionIs there any good tutorial and example for restful web services using jquery & xml? I am pretty new to restful web services
How about "Enterprise Mashups with RESTful Web Services and jQuery "? That has code details along with an explanation of how it works.
Part 1
Part 2
It depends on the backend technology you're using, but a general solution with jQuery would be using $.ajax
:
$.ajax( {
type:'post', //Could be 'get' depending on your needs
url:'http://yoursite.com/yourwebservice',
dataType: 'xml',
success:function(data) {
//Here you have 'data' as xml.
//You can process 'data' here
}
});
Hope this helps. Cheers
one more example
this will make an ajax call on page load for .net webservices
$(document).ready(function() {
$.ajax({
type: "POST",
url: "RSSReader.asmx/GetRSSReader",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
//the result will be in msg
}
});
});
精彩评论