-
What is AJAX?
AJAX is an acronym for Asynchronous JavaScript and XML, it is a combination of several technologies allowing for asynchronous transfer of data using ONLY portions of data which are reloaded into the webpage as opposed to the whole webpage being reloaded.
-
What is so new and great about AJAX?
Traditional web pages work by sending the full webpage to the server and having the server resending this webpage back to the client and reloaded. With AJAX, only a portion of the webpage is sent and reloaded…meaning “no flicker” and a much more fluid, faster response. Great for basic validation and page fluidity.
-
What major companies use AJAX?
All the major players including Google Maps, GMAIL, YouTube, Facebook, Yahoo Weather, RSS Feeds, and much more.
-
Create a JSON list of US states which could then be used in an AJAX call.
var US = {"AL":{"count":"0","name":"Alabama","abbr":"AL"},"AK":{"count":"1","name":"Alaska","abbr":"AK"},"AZ":{"count":"2","name":"Arizona ","abbr":"AZ"},"AR":{"count":"3","name":"Arkansas","abbr":"AR"},"CA":{"count":"4","name":"California ","abbr":"CA"} };
-
Give the most simplest steps needed for an AJAX call.
An event triggers in Javascript a function which then uses an XMLHttpRequest being sent to the server, processed, and a response is sent back to the user's browser where the response is interpreted using JavaScript and the user's webpage is updated using the DOM.
-
What formats are used when receiving data from an AJAX call?
The most common would likely be Json but plain text and XML can also be used.
-
Write a simple AJAX function call which replaces the content of a "div" element to the content located in a file.
var xmlhttp;if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();} xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById("myDiv").innerHTML = xmlhttp.responseText;}} xmlhttp.open("GET","ajax_info.txt",true);xmlhttp.send();
-
Explain the steps needed to write a simple ASP.NET page which will have label contents updated using AJAX when clicking a button.
(1) Place two controls on the page, the ScriptManager and the UpdatePanel (2) in the UpdatePanel, create a label and a button (3) on server side, create a button event which provides a message and the server date and time value (4) you can toggle between Ajax and a full postback by setting the ScriptManager attribute of enablepartialrendering to true / false.
-
Write a simple jQuery function to popup an alert box with a Person object name using JSON.
- $("button").click(function(){
- $.getJSON("demo.js", function(result){
- $.each(result, function(i, username){
- alert('Username: ' + username);
- });
- });
- });
-
An angular response object returned from an API call using the $http object has what six properties?
data – The response body transformed with the transform functions.
status – HTTP status code of the response.
headers – Header information.
config – The configuration object that was used to generate the request.
statusText – HTTP status text of the response.
xhrStatus – complete, error, timeout or abort.
-
Write an Angular $http get method containing the simplist form (no error handling)... something we might see to populate a drop down or similar object.
function getUser($http) { return $http.get('...').then(function(response) { return response.data; }); }
-
What is an angular promise? Explain.
A Promise is made when an $http request is made of the server, promising that an asynchronous message will be resolved (request success) or rejected (request failure) with a response object.
-
How do you consume a REST web service using angularJs?
$http.get('/someUrl', config).then(function(response) { }, function(response) { });
$http.get('/someUrl/' + id, config).then(function(response) { }, function(response) { });
$http.post('/someUrl', model, config).then(function(response) { }, function(response) { });
$http.put('/someUrl/' + id, model, config).then(function(response) { }, function(response) { });
$http.delete('/someUrl/' + id, config).then(function(response) { }, function(response) { });
|
|