How to use JQuery AJAX Method to Call an API?

In this blog in am going to explain that How to use JQuery AJAX Method to Call an API for to load data from external website or external File of etc, by calling APIs, and get the response in JSON or XML formats. So first thing I am going to create a html file and import jquery cdn. If you want to bootstrap css, & js cdn the you can copy from this link Click Here as below-

In this code I am using bootstrap cdn with jQuery cdn after that a Script tag in this script tag ajax function call with json data for getting data showing in cosole.log. If you using first time jQuery then you can right button of mouse and select inspect (Ctrl+shift+i) after that showing below tab then select console tab. When you click Here button from document then showing all data which retrieve.

Tagged : / / / /

JavaScript Cheat Sheet — JSON, Loops, and Promises

JavaScript is one of the most popular programming languages for web programming.

In this article, we’ll look at the basic syntax of modern JavaScript

JSON

We can create JSON strings from JavaScript objects with the JSON.stringify method:

And we can convert JSON strings back to JavaScript objects with JSON.parse :

const obj = JSON.parse(json);

We can use it to store data in local storage.

We’ve to convert objects into strings first to store them.

To store objects we call localStorage.setItem :

The first argument is the key.

And we can get data by their keys with getItem :

localStorage.getItem(‘json’)

Loops

avaScript comes with various kinds of loops.

One kind of loop is the for loop:

for (let i = 0; i < 10; i++) { console.log(i); }

We can loop through any kind of iterable object with the for-of loop:

for (let i of custOrder) { console.log(i); }

Some iterable objects include arrays, strings, and node lists.

Another kind of loop is the while loop:

There’s also the do-while loop:

The break keyword lets us end the loop early:

The continue keyword lets us skip to the next iteration:

Data Types

JavaScript comes with various data types.

They include:

Objects

We can create an object with curly braces:

It has properties and methods.

this is the student object itself.

We can call fullName with student.fullName() .

And we can assign values to properties with:

student.age = 19;

Promises

We can create promises with the Promise constructor:

We can resolve to fulfill the promise with the sum.

And we call reject to reject the promise with an error.

Then we can call then to get the resolved value and catch to get the error values:

Conclusion

We can work with JSON, local storage, promises, and loops with JavaScript.

Tagged : / / /