Post your solution to the May 5 In-Class Exercise to this thread.
Best,
Chris
<pre> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JSONP 5/5/2021</title> <script> function findTotalResults(obj) { alert(obj.totalResults); } </script> <!-- for some reason the self-closing script tag wasn't working for me --> <script src="https://www.yioop.com/s/news?f=json&callback=findTotalResults"></script> </head> <body> <p>CS 174 JSONP In-Class Exercise, 5/5/2021</p> </body> </html> </pre>
<!DOCTYPE html> <html> <head> <title> JSONP </title> </head> <body> <script> function findTotalResults(obj) { alert(obj.findTotalResults); } </script> <script src="https://www.yioop.com/s/news/?f=json&callback=findTotalResults" /> </body>
</html>
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>In-class exercise</title> </head> <body> <script> function findTotalResults(obj) { alert(obj.totalResults); } </script>
<script src="https://www.yioop.com/s/news?f=json&callback=findTotalResults"></script>
</body> </html>
<!DOCTYPE html> <head> </head> <body> <script> function findTotalResults(obj) { alert(obj.totalResults); } </script> <script src="https://www.yioop.com/s/news?f=json&callback=findTotalResults"></script> </body> </html>
(Edited: 2021-05-05) <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
function findTotalResults(obj){
alert(the total number of results: ${obj.totalResults});
}
</script>
<script src="https://yioop.com/s/news?f=json&callback=findTotalResults"></script>
</body>
</html>
<nowiki> <!doctype HTML> <html lang='en-US'> <head> <meta charset="utf-8"/> <title>Exercise 5/5</title> </head> <body> <script> function findTotalResults(results) { alert(results.totalResults); } </script> <script src="https://www.yioop.com/s/news?f=json&callback=findTotalResults"> </script>
</body> </html>
</nowiki>
(Edited: 2021-05-05)<!DOCTYPE html> <html lang="en"> <head> <title>In-Class Exercise</title> </head> <body> <script> function findTotalResults(obj) { alert(obj.totalResults); } </script> <script src="https://www.yioop.com/s/news?f=json&callback=findTotalResults"></script> </body> </html>
<nowiki> <!DOCTYPE html> <head> <title>May 5</title> <meta charset="UTF-8"/> </head> <body>
<script> function findTotalResults(results) { alert(results.totalResults); } <script> <script src="https://www.yioop.com/s/news?f=json&callback=findTotalResults" /> </body> </html> </nowiki>
<pre> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <script> function findTotalResults(obj) { alert("total results": obj.totalResults) }</pre><pre> </script> <body> <script src="https://www.yioop.com/s/news?f=json&callback=findTotalResults"></script> </body> </html> </pre>
(Edited: 2021-05-05)