@@ -57,7 +57,7 @@ JavaScript Object Notation |
57 | 57 | -------------------------- |
58 | 58 |
|
59 | 59 | Here is the definition of JavaScript Object Notation (JSON) from |
60 | | -www.[json.org](http://www.json.org/) |
| 60 | +<http://www.json.org>. |
61 | 61 |
|
62 | 62 | > JavaScript Object Notation, or JSON, is a lightweight data-interchange |
63 | 63 | > format. It is easy for humans to read and write. It is easy for |
@@ -110,18 +110,13 @@ another object; for example: |
110 | 110 | "comments": [] |
111 | 111 | } |
112 | 112 | ], |
113 | | - "totalPost": 2, |
114 | | - "getData": function () { |
115 | | - return new Data().getDate(); |
116 | | - } |
| 113 | + "totalPosts": 2 |
117 | 114 | } |
118 | 115 |
|
119 | 116 | In this example, we have an object with the `posts` property. The |
120 | 117 | value of the `posts` property is an array of objects with each one of |
121 | 118 | them having `title`, `votes`, and `comments` keys. The `votes` property |
122 | | -holds a number primitive, whereas `comments` is an array of strings. We |
123 | | -also can have functions as values; in this case, the key is called a |
124 | | -method; that is, `getData`. |
| 119 | +holds a number primitive, whereas `comments` is an array of strings. We cannot have function as fields. JSON is strictly a data structure. (We can have function in JS objects though.) |
125 | 120 |
|
126 | 121 | JSON is much more flexible and compact than XML or other data formats, |
127 | 122 | as outlined in this article: [JSON: The Fat-Free Alternative to |
@@ -753,8 +748,7 @@ once a user clicks the buttons. The aforementioned buttons call the |
753 | 748 | } |
754 | 749 |
|
755 | 750 | The code should be straightforward. We get the value of the city name |
756 | | -from the input box, check that it's not empty, and call `getDada()`, |
757 | | -which will make the XHR request to the server. You've already seen an |
| 751 | +from the input box (ID `city-name`). Then, we check that the city name is NOT empty, and call `getDada()`. This function `getData()` will make the XHR request to the server (Open Weather API). You've already seen an |
758 | 752 | example of the `$.ajax` request. Please note that the callback |
759 | 753 | function is named `fetchData`. This function will be called after |
760 | 754 | the browser gets the response from the OpenWeatherMap API. Needless to |
|