Top Banner
JQuery, JSON Web Technologies I. Zsolt Tóth University of Miskolc 2018 Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 1 / 29
29

JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

Jul 09, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery, JSONWeb Technologies I.

Zsolt Tóth

University of Miskolc

2018

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 1 / 29

Page 2: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

Introduction

Table of Contents

1 Introduction

2 JSONHierarchical Data ModelSyntaxApplications

3 JQuerySyntaxEvents, FunctionsPlug–ins

4 AJAXJQueryLayout

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 2 / 29

Page 3: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

Introduction

N–Tier Architecture

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 3 / 29

Page 4: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

Introduction

Client-Server Communication

ProtocolHTTP

VerbsStatus Codes

Content ?Challenges

Different platformsData formatsNetwork SecurityFirewall

Text basedHTTP XData formats

CSVXMLJSON

ProcessingJavaScriptJQuery

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 4 / 29

Page 5: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Hierarchical Data Model

Table of Contents

1 Introduction

2 JSONHierarchical Data ModelSyntaxApplications

3 JQuerySyntaxEvents, FunctionsPlug–ins

4 AJAXJQueryLayout

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 5 / 29

Page 6: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Hierarchical Data Model

Hierarchical Data Model

1960’sTree structure1-to-many relationshipXMLJSON

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 6 / 29

Page 7: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Hierarchical Data Model

XML

eXtensible Markup LanguageData descriptiontext-basedtag

Schema definitionDTDXML Schema

+ Self contained+ Platform independent+ Readable+ Free, open standard

RSSAPI

SAXDOMJAXB

ApplicationsSOAP

- Huge- "slow" processing

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 7 / 29

Page 8: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Syntax

JavaScript Object Notation

text-basedSelf containedDesigned for data transferLanguage independentJavaScript syntaxHierarchical Data Model

{"name " : " John Johnson " ," s t r e e t " : " Oslo West 555" ," age " : 3 3 ," phone " : "555 1234567"}

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 8 / 29

Page 9: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Syntax

XML vs. JSON

XML+ Flexible+ Extendable+ Namespaces+ Readable+ XML Schema+ XPath, XSLT, XQuery- Long- "slow" processing

JSON+ Compact+ Simple+ Easy-to-learn+ "fast" processing- Simple syntax- Hard-to-read

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 9 / 29

Page 10: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Syntax

Syntax

Name-Value pairscomma separated

ParenthesesNot tag

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 10 / 29

Page 11: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Syntax

string

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 11 / 29

Page 12: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Syntax

value

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 12 / 29

Page 13: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Syntax

Number

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 13 / 29

Page 14: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Syntax

Array

Array of valuesVarious types

Use brackets [, ]

comma separated

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 14 / 29

Page 15: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JSON Applications

Language Support

Many JSON LibrariesPlatform independent

JavaScripteval()

PHPPHP 5.2json

JavaJackson JSON Processororg.jsonjson–simplegoogle–gsonxjc, JAXB

C#fastJSONJSON.NET

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 15 / 29

Page 16: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Syntax

Table of Contents

1 Introduction

2 JSONHierarchical Data ModelSyntaxApplications

3 JQuerySyntaxEvents, FunctionsPlug–ins

4 AJAXJQueryLayout

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 16 / 29

Page 17: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Syntax

Syntax

JavaScript LibraryEasy-to-useEvent handlingAnimationsAJAXPlug–ins

$ functionCSS selectors

tag nameId #class .

"write less, do more"

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 17 / 29

Page 18: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Syntax

Usage

JavaScriptExternal filelinking

OnlineLocal file

$ ( t h i s ) . h ide ( ) ;$ ( " . t e s t " ) . h ide ( ) ;$ ( "# content " ) . html (" He l lo World ! " ) ;

< s c r i p t s rc =" jquery −1.10.2. min . j s " / >< s c r i p t s rc =" h t t p : / / a jax . aspnetcdn . com/ a jax / jQuery / jquery −1.10.2. min . j s " / >

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 18 / 29

Page 19: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Syntax

Selectors

tag name$("p")

Select all tag

Idid attribute$("#id")

Single node

Osztály alapúclass attribute$(".class")

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 19 / 29

Page 20: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Events, Functions

Events

Mouse Keyboard Form Documentclick keypress submit loaddbclick keydown change resizemouseenter keyup focus scrollmouseleave blur unload

$ ( " p " ) . c l i c k ( f u n c t i o n ( ) {$ ( t h i s ) . h ide ( ) ;

} ) ;

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 20 / 29

Page 21: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Events, Functions

Functions

. operatorfunction()

function name()

html()html(content)text()css()

Effectshide()show()toggle(speed,callback)fadeIn()fadeOut()slide{Up,Down,Toggle}()animate()

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 21 / 29

Page 22: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Events, Functions

Callback

function as parameterC function pointerC# delegateGeneralizationUI Design

$ ( " but ton " ) . c l i c k (f u n c t i o n ( ) {

$ ( " p " ) . h ide ( " slow " ,f u n c t i o n ( ) {

a l e r t (" The paragraph i snow hidden " ) ;

} ) ;} ) ;

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 22 / 29

Page 23: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

JQuery Plug–ins

Plug–in

Plug–in repositoryLabels

uiformanimationinputsliderresponsiveeffect. . .

ExamplesSelectableUI Highlight EffectSliderDatepickerMenuSortableAutocompletePeity (chart)

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 23 / 29

Page 24: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

AJAX JQuery

Table of Contents

1 Introduction

2 JSONHierarchical Data ModelSyntaxApplications

3 JQuerySyntaxEvents, FunctionsPlug–ins

4 AJAXJQueryLayout

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 24 / 29

Page 25: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

AJAX JQuery

Asynchronous JavaScript And XML

Request dataAsynchronousDoes not require refreshPage refresh XData is processed at clientside

$ ( document ) . ready (f u n c t i o n ( ) {

$ ( " but ton " ) . c l i c k (f u n c t i o n ( ) {

$ ( "# d iv1 " ) . load (" demo_test . t x t " ) ;

} ) ;} ) ;

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 25 / 29

Page 26: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

AJAX JQuery

$.ajax

urlsettings

acceptsasynccomplete (function)contextdatasucccess (function). . .

$ . a jax ( {u r l : u r l ,data : data ,success : success ,dataType : dataType

} ) ;

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 26 / 29

Page 27: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

AJAX JQuery

Get

GET requestcalls $.ajax()Parameters

urldatasuccessdataType

xmljsonscripthtml

$ . get ( " a jax / t e s t . html " ,f u n c t i o n ( data ) {

$ ( " . r e s u l t " ) . html (data ) ;

} ) ;

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 27 / 29

Page 28: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

AJAX JQuery

Post

POST requestcalls $.ajax()Parameters

urldatasuccessdataType

xmljsonscripthtml

$ . post ( " a jax / t e s t . html " ,f u n c t i o n ( data ) {

$ ( " . r e s u l t " ) . html (data ) ;

} ) ;

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 28 / 29

Page 29: JQuery, JSON - Web Technologies I.tothzs/edu/webtech/... · 2018-09-03 · JQuery Plug–ins Plug–in Plug–in repository Labels ui form animation input slider responsive effect:::

AJAX Layout

Layout

div + CSSAJAXChange content with JSSingle pageFragments

elements div

appearance CSSnavigation link X

links other sites X

Zsolt Tóth (University of Miskolc) JQuery, JSON 2018 29 / 29