filmov
tv
Calling live json web service using jquery ajax
Показать описание
Link for all dot net and sql server video tutorial playlists
Link for slides, code samples and text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
In this video we will discuss how to call a live weather web service that returns JSON data using jquery ajax.
For the purpose of this demo, we will be using the live weather web service that returns JSON data. The web service can be found at the following URL.
We want to retrieve weather data from the web service and display it on a web page.
Here is the HTML and jQuery code used in the demo
<html>
<head>
<script type="text/javascript">
$(document).ready(function () {
$('#btnGetWeather').click(function () {
var resultElement = $('#resultDiv');
var requestData = $('#txtCity').val() + ',' + $('#txtCountry').val();
$.ajax({
method: 'get',
data: { q: requestData },
dataType: 'json',
success: function (response) {
}
else {
}
},
error: function (err) {
alert(err);
}
});
});
});
</script>
</head>
<body style="font-family:Arial">
<table>
<tr>
<td>City</td>
<td><input type="text" id="txtCity" /></td>
</tr>
<tr>
<td>Country</td>
<td><input type="text" id="txtCountry" /></td>
</tr>
</table>
<input type="button" id="btnGetWeather" value="Get Weather Data">
<br /><br />
<div id="resultDiv">
</div>
</body>
</html>
Link for slides, code samples and text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
In this video we will discuss how to call a live weather web service that returns JSON data using jquery ajax.
For the purpose of this demo, we will be using the live weather web service that returns JSON data. The web service can be found at the following URL.
We want to retrieve weather data from the web service and display it on a web page.
Here is the HTML and jQuery code used in the demo
<html>
<head>
<script type="text/javascript">
$(document).ready(function () {
$('#btnGetWeather').click(function () {
var resultElement = $('#resultDiv');
var requestData = $('#txtCity').val() + ',' + $('#txtCountry').val();
$.ajax({
method: 'get',
data: { q: requestData },
dataType: 'json',
success: function (response) {
}
else {
}
},
error: function (err) {
alert(err);
}
});
});
});
</script>
</head>
<body style="font-family:Arial">
<table>
<tr>
<td>City</td>
<td><input type="text" id="txtCity" /></td>
</tr>
<tr>
<td>Country</td>
<td><input type="text" id="txtCountry" /></td>
</tr>
</table>
<input type="button" id="btnGetWeather" value="Get Weather Data">
<br /><br />
<div id="resultDiv">
</div>
</body>
</html>
Комментарии