onblur event or
an onkeyup event
in the desired form element;
or using addEventListener('blur', function-to-be-called))
onreadystatechange property of
XMLHttpRequest objectXMLHttpRequest (JS object) to perform asynchronous interaction with the servervariable = new XMLHttpRequest();
variable = new ActiveXObject("Microsoft.XMLHTTP");
header('Access-Control-Allow-Origin: http://localhost:4200');
// header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');
Refer to dealing with CORS
for more information on header setting for cross-site request.
XMLHttpRequest object
variable = new XMLHttpRequest();
onreadystatechange property of the
XMLHttpRequest object.
Note: Only the code is registered, not the function name.
xhr.onreadystatechange = receivePlace;
open() method of
the xhr object.
GET or POST)true) or
synchronous (false)GET is used
xhr.open("GET", "zipLookup?zip=" + zip, true)
send method
xhr.send();
| Value | readyState | Description |
|---|---|---|
| 0 | Request not initialized | After the XMLHttpRequest object is created
but before the open() method has been called,
the readyState property of the XMLHttpRequest object
is assigned a value of 0.
|
| 1 | Server connection established | After the open() method has been invoked successfully,
the readyState property of the XMLHttpRequest object
is assigned a value of 1.
|
| 2 | Request received | After the send() method has been invoked
and the HTTP response headers have been received,
the readyState property of the XMLHttpRequest object
is assigned a value of 2.
|
| 3 | Processing request | Once the HTTP response content begins to load,
the readyState property of the XMLHttpRequest object
is assigned a value of 3.
|
| 4 | Request finished and response is ready | Once the HTTP response content has finished loading,
the readyState property of the XMLHttpRequest object
is assigned a value of 4.
|
| Category | Status |
| Successful 2xx | 200 OK |
| Redirection 3xx | 301 Moved Permanently |
| 302 Found | |
| Client Error 4xx | 400 Bad Request |
| 401 Unauthorized | |
| 403 Forbidden | |
| 404 Not Found | |
| Server Error 5xx | 500 Internal Server Error |
| 503 Service Unavailable | |
| 504 Gateway Timeout |
print statement
doGet() method
and put the response in the usual Response object.
setContentType().
CC-BY-NC-SA 4.0 license.