How to Read an Object in jQuery
As a dynamic programming language for the web, jQuery can be used to perform many actions on a website. These include reading objects from other JavaScript applications that are outputted in the form of JSON, which is the standard for data and other kinds of information sent from object-oriented Javascript applications. Reading an object in jQuery is also known as parsing an object.
Instructions
-
-
1
Obtain the Javascript object using jQuery by calling the getJSON function. For example:
$(function(URL) {
$.getJSON("jsonExampleObj.js", function (json) {
-
2
Read the object by using the following jJSON function:
jJSON("title") = (function() {
response = {
values: [],
count: 0
};
-
-
3
Dictate how the objects should be handled by adding additional Javascript functions. For example:
$.each(json.attributes,function(i,itim) {
if (item.title != "undefined" && item.title != " ") {
response.count++;
response.values[i] = item.title;
}
});
return response;
})();
-
1