Skip to content

Instantly share code, notes, and snippets.

@vladanyes
Last active May 19, 2018 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladanyes/b806e93ff156b8d4d77ad04cf7a6e358 to your computer and use it in GitHub Desktop.
Save vladanyes/b806e93ff156b8d4d77ad04cf7a6e358 to your computer and use it in GitHub Desktop.
ajax
$(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