Simple App Demonstrating Callbacks & REST API Integration

Size
2,200 Kb
Views
24,288

How do I make an simple app demonstrating callbacks & rest api integration?

Simple App Demonstrating Callbacks & REST API Integration. What is a simple app demonstrating callbacks & rest api integration? How do you make a simple app demonstrating callbacks & rest api integration? This script and codes were developed by Aaron K Saunders on 25 September 2022, Sunday.

Simple App Demonstrating Callbacks & REST API Integration Previews

Simple App Demonstrating Callbacks & REST API Integration - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple App Demonstrating Callbacks & REST API Integration</title>
</head>
<body> <html>
<head> <title>Simple App - Callbacks - API</title> <!-- see https://getbootstrap.com/css/ --> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="application/javascript"></script>
</head>
<body class="container" onload="doOnLoad()"> <h2>Simple App - Callbacks - API</h2> <div> <h4>Documentation Links for what is covered here</h4> <ul style="font-size:larger"> <li> <a href="https://randomuser.me/" target="_blank"> A free API for generating random user data. Like Lorem Ipsum, but for people. </a> </li> <li> <a href="https://api.jquery.com/jquery.ajax/" target="_blank"> Documentation in jQuery $.ajax </a> </li> <li> <a href="http://www.sitepoint.com/use-jquerys-ajax-function/" target="_blank"> How to Use jQuerys $.ajax() Function </a> </li> </ul> </li> </div> <div> <h4>JSON Object that is the response <code>https://randomuser.me/api/</code> API call</h4> <pre id="response-content"></pre> <pre> <div style="color:red" id="error-content"></div> </pre> </div>
</body>
<!-- FOCUS ONLY ON THE CODE REGARDING CALLBACKS -->
<script type="text/javascript"> /** * success handler, callback function */ function successCallback(_data) { console.log(_data); // this is jquery code to add the response information // to the webpage at the div with the id '#response-content' $('#response-content').text(JSON.stringify(_data, null, 2)); } /** * error handler, callback function */ function errorCallback(_error) { console.log("error: " + _error); // this is jquery code to add the error information // to the webpage at the div with the id '#error-content' $('#error-content').text(JSON.stringify(_error, null, 2)); } /** * this function makes an API call using jQuery $ajax function * additional documentation is provided in the html page * * this function is call when the document is loaded, ie the page * is loaded in the browser */ function doOnLoad() { $.ajax({ url: 'https://randomuser.me/api/', dataType: 'json', success: successCallback, // <= callback function error: errorCallback // <= callback function }); }
</script>
</html>
</body>
</html>
Simple App Demonstrating Callbacks & REST API Integration - Script Codes
Simple App Demonstrating Callbacks & REST API Integration - Script Codes
Home Page Home
Developer Aaron K Saunders
Username aaronksaunders
Uploaded September 25, 2022
Rating 3
Size 2,200 Kb
Views 24,288
Do you need developer help for Simple App Demonstrating Callbacks & REST API Integration?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Aaron K Saunders (aaronksaunders) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!