-
-
Save vladanyes/b806e93ff156b8d4d77ad04cf7a6e358 to your computer and use it in GitHub Desktop.
ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$.ajax({ | |
url: "lines.txt", // path to file | |
dataType: 'text', // type of file (text, json, xml, etc) | |
success: function(data) { // callback for successful completion | |
$("#sentences").html(data); | |
}, | |
error: function() { // callback if there's an error | |
alert("error"); | |
} | |
}); | |
}); | |
$(document).ready(function(){ | |
$.ajax({ | |
url: "http://api.openweathermap.org/data/2.5/weather?APPID=YOUR_API_KEY&id=5128581&units=imperial", | |
dataType: 'json', | |
success: function(data) { --- data - то,что приходит с сервера(json чаще всего) | |
alert("Temperature is: " + data.main.temp ); | |
}, | |
error: function() { | |
alert("error"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment