In my misplaced put up on RESTful net service I exhibit how we will send XML response using RESTful web service. I additionally train who to create net service consumer utilizing java. Now let’s see tips on how to create jQuery Ajax Consumer to eat net service XML response. Earlier than continuing I like to recommend you to undergo my earlier put up about XML response.
So taking earlier instance as a Internet service lets write Ajax consumer to eat it.
Create a HTML web page and use html choose to pick particular automobile identify, jQuery selector will get the worth and create a URL, that URL then go to Ajax name to net service and get response in XML format.
Following jQuery reveals that Ajax Name…
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
$(doc).prepared(operate(){
$(‘choose’).change(operate(){
$.ajax(
{ url: ‘relaxation/xml/automobile/’+this.worth,
full: operate ( jsXHR, textStatus ) {
var xmlResponse = $.parseXML(jsXHR.responseText),
$xml = $(xmlResponse),
$make = $xml.discover(‘make’),
$worth = $xml.discover(‘worth’),
$carName = $xml.discover(‘car-name’);
$(‘h3#carMake’).html(“Manufacture: “+$make.textual content());
$(‘h3#carPrice’).html(“Value: “+$worth.textual content());
$(‘h3#carName’).html(“Automotive Title: “+$carName.textual content());
}
}
);
});
});
|
Name to net service return response in XML format. You may see that response in FireBug.
Output will look just like following screenshot in your browser.
Glad Coding 🙂
Supply techzoo.org