AJAX Flashcards
What does AJAX stand for?
Asynchronous
Javascript
And
XML
What is AJAX used for?
Using Javascript on server after webpage has loaded to get more information in the form of XML (or JSON)
What is XML used for?
Store data Transfer data Terminology it's a data format that sits there contract
What problems exist with cross domain policies in browsers? What’s a solution?
You are not allowed to make AJAX requests to a webpage perceived to be on a different server by the browser
JSONP is a solution
What does JSON stand for?
JavaScript
Object
Notation
What is the advantage to using JSON over XML?
JSON files look same as code used to create JS objects
eval() function in JS converts JSON to JS objects (eval used when using JSON instead of JSONP)
make sure you trust where you are getting this code from
What are some features of JSON?
Data is in name/value pairs
Data is separated by commas
Curly braces hold objects
Square brackets hold arrays
When would we use JSON over XML
- Messages don’t need to be validated, or validating their deserialization is simple
- You’re not transforming messages, or transforming their deserialization is simple
- Your messages are mostly data, not marked-up text
- The messaging endpoints have good JSON tools
Why would we want processing to happen at client end rather than our server?
It costs us less
What does asynchronous mean? What about synchronous?
Asynchronous means that the browser will make the AJAX request and continue doing other things. Synchronous means the browser will stop what it’s doing until the AJAX call completes (has limited use case – sneaker drops).
When would we use XML over JSON?
- You need message validation
- You’re using XSLT
- Your messages include a lot of marked-up text
- You need to interoperate with environments that don’t support JSON
Explain the process of an AJAX call being sent out
1) Browser: Event occurs so XMLHttpRequest object created and HttpRequest sent to internet
2) Servers: Process request, send response and data through internet back to browser
3) Browser: Process data using JS and update content
Explain how AJAX violates security rules regarding percent escaping of reserved characters in POST data
Allows direct injection of hostile code into SQL schemas, which can be things such as PHP code for later retrieval and execution on the host.
Why can’t AJAX be trusted to do complete scanning over every communication?
It doesn’t escape reserved GET and POST characters. Allows direct injection of hostile code into SQL schemas.