• Nie Znaleziono Wyników

From HTML to PostGIS

N/A
N/A
Protected

Academic year: 2021

Share "From HTML to PostGIS"

Copied!
8
0
0

Pełen tekst

(1)

AJAX

From HTML to PostGIS

Michał Okulewicz

Wydział Matematyki i Nauk Informacyjnych Politechnika Warszawska

Michał Okulewicz HTML2PostGIS

(2)

Lecture plan

1 AJAX

Plain XMLHTTPRequest Fetch API

(3)

AJAX Plain XMLHTTPRequest Fetch API

Definition

AJAX = Asynchronous JavaScript+XML

Use JavaScript and XML-based messages to communicate from within a web page with the server without refreshing the HTML page at the same time

With AJAX, we are taking a bunch of dusty old technologies and stretching them well beyond their original scope – AJAX in Action, Manning, 2006

Michał Okulewicz HTML2PostGIS

(4)

Sample plain JS code

(5)

AJAX Plain XMLHTTPRequest Fetch API

Sample plain JS code cont.

Michał Okulewicz HTML2PostGIS

(6)

Crucial steps of AJAX request

Setting up the data handler req.onreadystatechange = processReqChange;

Initializing the connection req.open(‘‘GET’’, url, true);

Sending the request req.send(null);

(7)

AJAX Plain XMLHTTPRequest Fetch API

GET and POST differences

GET

Arguments are sent within the address argument

req.open(‘‘GET’’,

‘‘script?name=John&surname=Major’’, async);

req.send();

POST

Arguments are sent within the body of the message and its content type needs to be specified

req.open(‘‘POST’’, ‘‘script’’, async);

req.setRequestHeader(‘‘Content-type’’,

‘‘application/x-www- form-urlencoded’’);

req.send(‘‘name=John&surname=Major’’);

Michał Okulewicz HTML2PostGIS

(8)

A fetch API request

Complete introduction to Fetch API

So long XHR - another introduction to Fetch

Why you shouldn’t use Fetch

Cytaty

Powiązane dokumenty

jest wykonana po stronie serwera jako odpowiedź na akcję Ajax po stronie przeglądarki. Metoda

3) Użycie atrybutu listener – przygotowanie odpowiedzi po stronie serwera na akcję Ajax tzn zawiera odwołanie do metody, która. jest wykonana po stronie serwera jako odpowiedź

• Biblioteka JS pozwala na osadzenie wyszukiwarki WWW w kodzie HTML, natomiast model REST udostępnia zasoby Google skryptom przetwarzanym po stronie serwera (np. PHP, Perl)...

• Document Object Model Level 2 Events (add/removeEventListener).. • Creating and changing the styles on

• jQuery speeds up writing the code and provides universal API for all browsers. • plain JavaScript code will always be faster (if

• The current idea are Single Page Applications consisting of HTML/CSS layout utilized by JavaScript application with content provided from REST services in a form of JSON

• Before the cell is updated set its background to red colour and if the update is a success change it to white (you may add a Thread.Sleep on the server side to observe

• To configure methods as a REST style services one should configure them by specifying RequestFormat,. ResponseFormat in