vef1-2024

Vefforritun 1 kennd haustið 2024

View the Project on GitHub vefforritun/vef1-2024

Fyrirlestur – HTTP og form

Vefforritun 1 — TÖL107G

Ólafur Sverrir Kjartansson, osk@hi.is


Villumeðhöndlun


Has the page loaded yet? Did the HTTP request for the JavaScript succeed? Did the HTTP request for the JavaScript complete? Does the corporate firewall block JavaScript? Does their ISP or mobile operator interfere with downloaded JavaScript? Have they switched off JavaScript? Do they have add‐ons or plug‐ins installed which inject script or alter the DOM in ways you didn’t anticipate? Is the Content Delivery Network up?

Everyone has JavaScript, right?


Unobtrusive JavaScript

Alveg eins og við aðskiljum útlit frá efni viljum við aðskilja forrit frá efni.

Tengt progressive enhancement er hugtakið unobtrusive JavaScript.



1. Identify core functionality.

2. Make that functionality available using the simplest possible technology.

3. Enhance!

Resilient Web Design, chapter 6: Steps


Some designers have misunderstood progressive enhancement to mean that all functionality must be provided to everyone. It’s the opposite. Progressive enhancement means providing core functionality to everyone. After that, it’s every browser for itself.

Resilient Web Design, chapter 5: Layers


Verkefni


Framendi VS bakendi

Mynd af framendi vs bakenda


Sagan



Request—response


Server


Request


Request – dæmi

GET / HTTP/1.1
Host: example.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Firefox/93.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

Response


Response – dæmi

HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Mon, 25 Oct 2021 08:39:07 GMT
Expires: Mon, 01 Nov 2021 08:39:07 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Vary: Accept-Encoding
Content-Length: 648

<html>
...

HTTP aðferðir



Hausar – headers


Dæmi um request hausa


Dæmi um response hausa


Stateless


Stöðukóðar — status codes

Þegar þjónn svarar með response gefur hann upp stöðukóða, sem tölu og lesanlegan texta


Dæmi um stöðukóða



URL


HTTP aðferðir og <form>


<form method="get">

<form method="get" action="">
  <label>
    Nafn: <input type="text" name="name">
  </label>
  <button>Senda</button>
</form>

<form method="post">

<form method="post" action="">
  <label>
    Name: <input type="text" name="name">
  </label>
  <button>Senda</button>
</form>