Mul$media im Netz (Online Mul$media) Wintersemester 2014/15. Übung 06 (Haup-ach)

Similar documents
Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 07 Minor Subject

Multimedia im Netz (Online Multimedia) Wintersemester 2014/15. Übung 11 (Hauptfach)

Mul$media im Netz (Online Mul$media) Wintersemester 2014/15. Übung 03 (Haup9ach)

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Minor Subject

Multimedia im Netz Online Multimedia Winter semester 2015/16

Task 1: JavaScript Video Event Handlers

Multimedia im Netz Online Multimedia Winter semester 2015/16

Task 1: JavaScript Video Event Handlers

Session 18. jquery - Ajax. Reference. Tutorials. jquery Methods. Session 18 jquery and Ajax 10/31/ Robert Kelly,

Jquery Ajax Json Php Mysql Data Entry Example

Assignment 11 (NF) - Repetition

IN Development in Platform Ecosystems Lecture 3: json, ajax, APIs

CSCB20 Week 11. Introduction to Database and Web Application Programming. Anna Bretscher* Winter 2017

LFE Medieninformatik WS 2016/2017

Web Focused Programming With PHP

Form Processing in PHP

Client Side JavaScript and AJAX

Multimedia im Netz Online Multimedia Winter semester 2015/16

WEBD 236 Web Information Systems Programming

SEEM4570 System Design and Implementation. Lecture 6 Game Part II

HTTP Communication on Tizen

Week 13 Thursday (with Page 5 corrections)

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

Multimedia im Netz Online Multimedia Winter semester 2015/16

Jquery.ajax Call Returns Status Code Of 200 But Fires Jquery Error

MI1004 Script programming and internet applications

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services

CENG 256 Internet Programming Draft

Ajax or AJAX? The acronym AJAX has changed to the term Ajax, which does not represent specific technologies

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes

CSC 405 Computer Security. Web Security

Creating an Online Catalogue Search for CD Collection with AJAX, XML, and PHP Using a Relational Database Server on WAMP/LAMP Server

CSCE 120: Learning To Code

TUTORIAL: D3 (1) Basics. Christoph Kralj Manfred Klaffenböck

jquery to connect with DynamoDB via Lambda API March 9-10, 2017 CS160 Section

,

JavaScript Specialist v2.0 Exam 1D0-735

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages

Computer Science Department

User Interaction: jquery

Fall Semester (081) Module7: AJAX

Lecture 29 11/4/15. CMPSC431W: Database Management Systems. Instructor: Yu- San Lin

Working Bootstrap Contact form with PHP and AJAX

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett

Project Part 2 (of 2) - Movie Poster And Actor! - Lookup

All samples, demos, slides & recording will be available later today for download at blogs.infragistics.com

This project will use an API from to retrieve a list of movie posters to display on screen.

jquery and AJAX

CS Final Exam Review Suggestions - Spring 2018

Serverless Single Page Web Apps, Part Four. CSCI 5828: Foundations of Software Engineering Lecture 24 11/10/2016

ASP.NET AJAX adds Asynchronous JavaScript and XML. ASP.NET AJAX was up until the fall of 2006 was known by the code-known of Atlas.

This is CS50. Harvard College Fall Quiz 1 Answer Key

TIME SCHEDULE MODULE TOPICS PERIODS. HTML Document Object Model (DOM) and javascript Object Notation (JSON)

Web client programming

AJAX Programming Chris Seddon

Last &me: Javascript (forms and func&ons)

XMLHttpRequest. CS144: Web Applications

Jquery Manually Set Checkbox Checked Or Not

Understanding JavaScript Event-Based Interactions. Saba Alimadadi Sheldon Sequeira Ali Mesbah Karthik Pattabiraman

iframe programming with jquery jquery Summit 2011

Dingle Coderdojo 6. Project Part 2 (of 2) - Movie Poster And Actor! - Lookup. Week 6

Overview of Forms. Forms are used all over the Web to: Types of forms: Accept information Provide interactivity

Kyle Rainville Littleton Coin Company

Networking & The Web. HCID 520 User Interface Software & Technology


Elementary! Incorporating BlueMix, Node-RED and Watson in Domino applications


16. Objects & JSON. Dr. Dave Parker. Informa;on and the Web, 2014/15

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

webkitpony Documentation

Welcome to CS50 section! This is Week 10 :(

VidyoEngage for Genesys Widgets

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN

CSC 405 Computer Security. Web Security

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

PHP. MIT 6.470, IAP 2010 Yafim Landa

Making applica+ons with Java. Text Technologies 2013 Chris Culy

Ajax- XMLHttpResponse. Returns a value such as ArrayBuffer, Blob, Document, JavaScript object, or a DOMString, based on the value of

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to:

CS50 Quiz Review. November 13, 2017

This is CS50 CS164. Mobile Software Engineering

Intro To Javascript. Intro to Web Development

CSC 443: Web Programming

Marketo Forms Integration Guide

src1-malan/ajax/ajax1.html ajax1.html Gets stock quote from quote1.php via Ajax, displaying result with alert().

HTTP Communication on Tizen (Tizen Ver. 2.3)

INF5750. Introduction to JavaScript and Node.js

Databases/JQuery AUGUST 1, 2018

Index. C CakePHP framework, 232 Cascading Style Sheets (CSS)

Abstract. 1. Introduction. 2. AJAX overview

Notes General. IS 651: Distributed Systems 1

JavaScript CSCI 201 Principles of Software Development

In this exercise we shall be using jsfiddle.net to build a simple data driven web site in HTML5. Building Blocks

INFO/CS 4302 Web Informa6on Systems

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

Introduc)on to Computer Networks

Comet and WebSocket Web Applications How to Scale Server-Side Event-Driven Scenarios

AngularJS AN INTRODUCTION. Introduction to the AngularJS framework

Development of Web Applications

Submitting forms (client-side)

Transcription:

Mul$media im Netz (Online Mul$media) Wintersemester 2014/15 Übung 06 (Haup-ach) Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-1

Today s Agenda Flashback: 5 th Tutorial Announcements jquery: AJAX Code- A- Long: Filtering a Movie List Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-2

Flashback Explain a concept from last week s tutorial to your grandmother Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-3

Announcements Assignment 06 Assignment 06 is due in 2 weeks. Tutors will help you with your programming assignment next week and answer your ques6ons. Please review the learning material and your assignments. Prepare ques6ons, and send them to tobias.stockinger@ifi.lmu.de in advance. Evalua6on There is going to be a small evalua6on of the tutorials during the next two weeks. You benefit from your construc6ve feedback right away Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-4

Assignment Submissions 70 60 50 40 30 20 10 0 64 51 40 31 25 9 3 4 2 4 A01 A02 A03 A04 A05 HF NF Linear (HF) 17.11.2014 15:50h Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-5

Challenge If more than 75 students (HF & NF) submit assignment 06, there will be a short mock exam prior to the final exam. hhps://openclipart.org/detail/168636/challenge- accepted- by- tavin Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-6

jquery Books Ruher, Jake. Smashing JQuery. John Wiley & Sons, 2011. Duckeh, Jon. JavaScript and JQuery: Interac6ve Front- End Web Development. John Wiley & Sons, (2014). Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-8

AJAX (ˈeɪdʒæks) Asynchrounous Javascript And XML Allows passing around data between client- and server- side applica6ons back and forth without refreshing the page AJAX requests (also: XHR = XML HhpRequest): GET: retrieve data no manipula6on on the server POST: retrieve and/or modify data Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-9

AJAX and jquery jquery offers methods for AJAX- requests: $.ajax() convenience methods: $.get(), $.post(), $.load()... Advantages: ease- of- use readability cross- browser compa6bility Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-10

Loading HTML Content HTML Content from the same site or server can be loaded into certain elements with $.load() Example function init(){ // this only works with local resources $("#container").load('bavariaipsum.html'); } $(document).ready(init); Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-11

Example: Loading an XML File $.ajax({ url : 'movies.xml', success : function(data){ // data = xml document $("body").append(data.childnodes); } }); $.ajax() documenta6on: hhps://api.jquery.com/jquery.ajax/ Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-12

Example: Loading an XML File $.ajax({ url : 'movies.xml', success : function(data){ // data = xml document $("body").append(data.childnodes); } }); Callback func6on. Once the data has been loaded, this func6on is called. It can take a while for this to be called why? $.ajax() documenta6on: hhps://api.jquery.com/jquery.ajax/ Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-13

Parameters: Example (I) <DOCTYPE html> <html> <head lang="en"> <meta charset="utf-8"> <title>api Test</title> <script src="jquery.js"></script> <script> // our code </script> </head> <body> <form id="contactform"> <label for="firstname">first Name:</label> <input type="text" id="firstname" name="firstname" /> <label for="lastname">last Name:</label> <input type="text" id="lastname" name="lastname" /> <input type="submit" value="submit"/> </form> <div id="result"> <-- all asynchronously loaded content will be put here --> </div> </body> </html> Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-14

Parameters: Example (II) <script> function init(){ function successcallback(data){ $("#result").html(data); } $("#contactform").submit(function(event){ event.preventdefault(); // if we don't do this, the page is actually var self = $(this); // this --> #contactform var firstname = self.find("#firstname").val(); var lastname = self.find("#lastname").val(); $.ajax({ url : 'apiscript.php', // the script we're calling type: 'POST', // the method we use data : { // the data we pass to the script firstname : firstname, lastname : lastname }, datatype : "text", // the expected response data type success : successcallback // what to do if we succeed }); }); } $(document).ready(init); </script> Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-15

PHP Script: apiscript.php <?php $firstname = $_POST['firstName']; $lastname = $_POST['lastName']; echo "First Name: $firstname <br />"; echo "Last Name: $lastname"; Ludwig- Maximilians- Universität München Mul6media im Netz WS 2012/13 - Übung 6-16

.serialize() <script> function init(){ function successcallback(data){ $("#result").html(data); } $("#contactform").submit(function(event){ event.preventdefault(); // if we don't do this, the page is actually var data = $(this).serialize(); $.ajax({ url : 'apiscript.php', // the script we're calling type: 'POST', // the method we use data : data, // the serialized data datatype : "text", // the expected response data type success : successcallback // what to do if we succeed }); }); } $(document).ready(init); </script> Ludwig- Maximilians- Universität München Mul6media im Netz WS 2012/13 - Übung 6-17

DataType The DataType field allows us to specify the type of data that we expect from the server: Text HTML Script JSON Ludwig- Maximilians- Universität München Mul6media im Netz WS 2012/13 - Übung 6-18

JSON JavaScript Object Nota6on Human- readable format for data exchange Based on key- value pairs example: { } "firstname": "John", "lastname": "Doe", "phone": [ { "type": "Home", "number": "5648978965" }, { "type": "Mobil", "nummer": "6458979878" } ] Ludwig- Maximilians- Universität München Mul6media im Netz WS 2012/13 - Übung 6-19

Example: AJAX- Request $(document).ready(function(){ // anonymous submit handler $("#contactform").submit(function(event){ // this prevents the page from refreshing event.preventdefault(); // make an object from our form data. // use console.log(data) to inspect it. var data = $(this).serialize(); $.ajax({ url: "json.php", type: "POST", data: data, datatype: "text", // callback with response data success: function(response){ // we fill this out later. } }); }); }); Ludwig- Maximilians- Universität München Mul6media im Netz WS 2012/13 - Übung 6-20

Example: PHP- Script json.php <?php // test script to send a response in json format. $data = $_POST; // we just return all parameters as json echo json_encode($data); Ludwig- Maximilians- Universität München Mul6media im Netz WS 2012/13 - Übung 6-21

Example: $.parsejson(data) // callback with response data success: function(response){ var output = $("#output"); var jsonresponse = $.parsejson(response); } // iterate over key/value pairs and // append each pair to the output container $.each(jsonresponse,function(key,value){ // create a container // use @key for its id // add some text var child = $('<div />').html(key+': '+value); child.appendto(output); }); Ludwig- Maximilians- Universität München Mul6media im Netz WS 2012/13 - Übung 6-22

AJAX Debugging To send requests manually (not via a script), you can use a number of tools For Chrome: Postman (also as standalone app) REST Console For Firefox: REST Client RESTeasy Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-23

Same Origin Policy (SOP) Part 1 Example: your script runs is executed at hhp://example.com Same origin: hhp://example.com hhp://example.com/ hhp://example.com/another/page Different origin: hhp://www.example.com hhp://example.com:3830/ hhps://example.com hhp://example.org Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-24

Same Origin Policy (SOP) Part 2 SOP tries to hamper cross site scrip$ng Error message example: SOP would block AJAX Mashups en6rely L It will become apparent once you start using your backend scripts remotely Solu6ons for Mashups: - Cross- Origin Resource Sharing (CORS) - JSON with Padding (JSONP) - Apache Proxies Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-25

Fast forward Write down 1 thing that you have learned today. Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-26

Assignment 6 Topic: Currency Converter Due in: 2 Weeks Due date: 01.12.2014 Programming consul$ng: 24.11.2014 (no or very few slides, no input, just programming help) Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-27

Thanks What are your ques$ons? Ludwig- Maximilians- Universität München Online Mul6media WS 2014/15 - Übung 06-28