@Mozar10 pretty sure you can get around that by either using jsonp or somehow getting the content to the same domain as the code causing the error.
As far as APIs go… I’ll make it super simple:
Hi, my name’s Todd. I’m the back-end developer at Google Maps. Your name is @Mozar10, you want to find out the best route between two addresses. Your JavaScript/jQuery/AJAX/Whatever sends a request to api.ToddsGoogleMapsRules.com/directions (This is called the API endpoint and the URL can be different for every site) with the two addresses. This is where my back-end system (written in PHP, Python, Ruby, JavaScript, C#, or even Java) takes over, runs the code to actually figure out the best route, then shoots that route back to your JavaScript/jQuery/AJAX/Whatever code, usually in the JSON format.
When your request hits my endpoint, what is really going on is whatever you send to me is hitting one of my server’s functions and then that function, just like your JavaScript code, is acting upon the parameters that you give it. This is why in URLs these days, you barely ever see .html. This is because most websites you visit, your browser’s requests are hitting server-side functions/methods that are dynamically shooting your browser a different page depending on some server-side processing. I.E. if you’re not logged in, my server aint gonna let you see the pages for people who are and etc…
The concept of APIs isn’t really that complicated. You hit up a server with a request, and it replies to your app, giving you the data/information that your app needs to function properly. You can even make an API yourself.
For example, I recently made a simple API which allows me to add bars and beers to my website’s database. What’s cool about this, is now I can do so from any device. I can easily make an Android or iOS app that hits up the API rather than only being able to use a web browser and web form.
The other thing that’s badass, is that I could program my entire website using APIs so that way, instead of having to send you a bunch of HTML markup, my server can simply send you raw json data and the client can handle the markup portion which greatly saves bandwidth and makes the user feel like the website is a lot faster.
This is the most practical way to describe an API as it is used and referred to in the curriculum of this website. As mentioned above though, in a general sense, they can technically be any code library or anyone else’s code that you re-use. For example, I can write a C# program that will use either Microsoft’s Windows API or Apple’s Mac OS API and do things on your computer such as check the system processor usage, available memory, delete files (can you say… viruses…) etc…