Internet Applications Spring 2008. Review Last week –MySQL –Questions?

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
AJAX Asynchronous JavaScript and XML. AJAX An interface that allows for the HTTP communication without page refreshment Web pages are loaded into an object.
1 AJAX – Asynchronous JavaScript and XML – Part II CS , Spring 2010.
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
PHP (2) – Functions, Arrays, Databases, and sessions.
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
19-Jun-15 Ajax. The hype Ajax (sometimes capitalized as AJAX) stands for Asynchronous JavaScript And XML Ajax is a technique for creating “better, faster,
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
Multiple Tiers in Action
Using AJAX Galip Aydin, Ahmet Sayar, and Marlon Pierce Community Grids Lab Indiana University.
The Document Object Model (DOM) & Asynchronous Javascript And XML (AJAX) : an introduction UFCEKG-20-2 : Data, Schemas and Applications.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
Internet Applications Spring Review Last week –PHP/JavaScript – Form –Questions?
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
Set 5: Perl and Database Connections
JavaScript & jQuery the missing manual Chapter 11
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
AJAX and Java ISYS 350. AJAX Asynchronous JavaScript and XML: – Related technologies: JavaScript, Document Object Model, XML, server-side script such.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
D2L Notes Be sure to submit your link in the dropbox provided on D2L You can just upload an empty text file if a file upload is required Do not use D2L.
1 Accelerated Web Development Course JavaScript and Client side programming Day 2 Rich Roth On The Net
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
Ajax - 1h. AJAX IS: A browser technology A technology that uses only JavaScript in the browser page A very efficient way of updating information A way.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
AJAX (also known as: XMLHTTP, Remote Scripting, XMLHttpRequest, etc.) Matt Warden.
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
THE WEBMASTERS: SENG + WAVERING.  On account of construction, we will be having class in room 1248 next week.
School of Computing and Information Systems CS 371 Web Application Programming AJAX.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
SYST Web Technologies SYST Web Technologies AJAX.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 AJAX – Asynchronous JavaScript and XML  Ajax is used to develop fast dynamic web applications  Allows web pages to be updated asynchronously by transferring.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 AJAX. AJAX – Whatzit? Asynchronous (content loading)‏ Javascript (logic & control)‏ And XML (request handling)‏
Javascript AJAX HTML WEB SERVER Asynchronous. Javascript HTML events DOM – document object model browser internal view of html page compute.
JavaScript, Sixth Edition Chapter 11 Updating Web Pages with Ajax.
JavaScript and Ajax Week 10 Web site:
PHP using MySQL Database for Web Development (part II)
Introduction to Dynamic Web Programming
CS 371 Web Application Programming
AJAX and REST.
AJAX – Asynchronous JavaScript and XML
Web Browser server client 3-Tier Architecture Apache web server PHP
JavaScript & jQuery AJAX.
Tutorial 6 PHP & MySQL Li Xu
DR. JOHN ABRAHAM PROFESSOR UTPA
Web Technologies Computing Science Thompson Rivers University
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Software Engineering for Internet Applications
Presentation transcript:

Internet Applications Spring 2008

Review Last week –MySQL –Questions?

This week Ajax Wrap-up coverage for exercises Class time to work on projects / exercises

Ajax Application model diagram Design considerations –Graceful degradation –Application fragmentation –Usability Components –JavaScript –HTTP request object

JavaScript Syntax –Function() {}; –/* comment */ Variable and function declarations –var newvariable = value; –function functionName() {content;} Control Structures –If (variable == value) { do stuff; } –For (var i=0; i<10; i++) { do stuff;} object.method.value –document.write –document.getElementById(‘navigation’);

DOM JavaScript An approach to writing JavaScript that appends functions to elements of the HTML document Reference getElementById getElementsByTagName parentNode childNodes nodeValue firstChild previousSibling

Ajax Basics Combination of JavaScript, browser functions, and data –Asynchronous JavaScript and XML Reproduces the GET/POST functionality of our forms Works with any data stream Can only request data from originating server

Ajax GET/POST GET –Retrieves a document from the server and allows client side document processing POST –Sends a querystring to server and enables complex data retrieval

responseText, responseXML Two forms of from xmlHTTPRequest responseText –Returns any text (HTML, JSON, etc) which can be manipulated by JavaScript after processing responseXML –Returns XML data that can be manipulated directly

Ajax Exercise Create a simple HTML page that contains no real content. Use a link to retrieve a document from the server and display it in our browser Skills –Utilizes Ajax GET method –Utilizes some DOM elements document.getElementById("bodymain"); details.innerHTML = request.responseText;

Ajax Function Framework getSomething() Initiate Connection getHttpObject() Initiates a browser object displayResponse() Retrieve data from server Waits for response Output to Page

getHttpObject() Responsible for creating XMLHttpRequest function getHTTPObject() { var xhr = false; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } return xhr; }

getSomething() Responsible for initiating a connection function getSomething(file) { var request = getHTTPObject(); if (request) { request.onreadystatechange = function() { displayResponse(request); }; request.open("GET", file, true) request.send(null); }

getSomething() Responsible for monitoring connection function displayResponse(request) { if (request.readyState == 4) { if(request.status == 200 || request.status == 304) { var details = document.getElementById("bodymain"); details.innerHTML = request.responseText; } else { alert(request.status); }

A quick POST example function updateFeed(file, query) { var request = getHTTPObject(); if (request) { request.onreadystatechange = function() { displayResponse(request); }; request.open ("POST", file, true); request.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded"); request.send(query); }

Element manipulation with DOM //Delete Elements elementToDelete = document.getElementById("bodymain"); parentElement = elementToDelete.parentNode; parentElement.removeChild(elementToDelete); //Create a new body element bodyElement = document.createElement("body"); bodyElement.setAttribute("id", "bodymain"); parentElement.appendChild(bodyElement); //Create a Text Node newLink = document.createElement("a"); newLink.setAttribute("href", "#"); newLink.setAttribute("onclick", "getSomething('./htmlfragment.html')"); linkText = document.createTextNode("Get some content"); newLink.appendChild(linkText); newBody.appendChild(newLink);

Putting it all together Part I –Create a basic HTML page –Download the HTML fragment –Create your JavaScript functions –Insert a link to initiate the Ajax Request Part II –Create a new JavaScript function that will use the DOM –Modify the Ajax Request to include a ‘delete content’ link

Skills needed for exercises 8 & 9 Ex 8 – External PHP functions file PHP require() function File management Ex 9 – Javascript Basics of JavaScript functions DOM scripting

Skills needed for exercises 10 & 11 Ex 10 – Login / Logoff functions More on HTML forms & PHP Writing and using Cookies Ex 11 - Ajax Ajax components Advanced JavaScript functions

Next week Final Projects due Quick presentation of class projects (1-2 min per person) Class wrap-up & evaluation

MySQL Open Source Relational Database At SILS –pearl.ils.unc.edu Relational database features Tables, Indexes, Queries SQL (Structured Query Language)

SQL Skills SQL – Structured query language –Uses a syntax with words like (select, where, insert, delete, from) to create logical statements Select column from tablename where limit = ‘value’; Insert into table (column, column) values (value 1, value 2); –A good reference

SQL Examples SELECT statements SELECT * from feeds where username = 'mitcheet'", SELECT * from feeds where id = ".$_REQUEST['feed'] INSERT statements INSERT INTO feeds (username, feedname, feedURL) values ('".$_REQUEST['username']."', '".$_REQUEST['feedName']."', '".$_REQUEST['feedUrl']."')"; DELETE statements DELETE from feeds where id = ".$_REQUEST['feedId']

MySQL functions in PHP Create a connection to the database $connection = mysql_connect($dbserver, $username, $pass); Select a database mysql_select_db($database, $connection); Run a query $result = mysql_query("SELECT * from feeds where username = 'mitcheet'", $connection); Get the results of the query as an array while ($row = mysql_fetch_array($result, MYSQL_NUM)) {} Close the connection mysql_close($connection);

MySQL Example function showFeed () { $connection = mysql_connect ("pearl.ils.unc.edu", "inls572_spring08", "yreuq572"); mysql_select_db("inls572_spring08", $connection); $result = mysql_query("SELECT * from feeds where id = ".$_REQUEST['feed'], $connection); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo $row[3]; }