Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // jquery
- $.ajax({
- url: "/api/getWeather",
- data: {
- zipcode: 97201
- },
- success: function( data ) {
- $( "#weather-temp" ).html( "<strong>" + data + "</strong> degrees" );
- }
- });
- // plain javascript
- var ajax = new XMLHttpRequest();
- ajax.onreadystatechange = function() {
- if( ajax.readyState == 4 && ajax.status == 200) {
- document.getElementById("weather-temp").innerHTML = "<strong>" + ajax.responseText + "</strong> degress";
- }
- };
- ajax.open("GET", "/api/getWeather?zipcode=97201", true);
- ajax.send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement