JavaScript, jQuery & AJAX. What is JavaScript? An interpreted programming language with object oriented capabilities. Not Java! –Originally called LiveScript,

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
The jQuery library. What is jQuery ? A javascript lightweight library Is very easy to use Is powerful Is cross-browser compatible Downloadable from jQuery.com,
JQuery A Javascript Library Hard things made eas(ier) Norman White.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
MSc. Publishing on WWW JavaScript. What is JavaScript? A scripting language devised by Netscape Adds functionality to web pages by: Embedding code into.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
JQuery. What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library that simplifies HTML document traversing and manipulation event handling.
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
JQuery CS 268. What is jQuery? From their web site:
Getting Started.  jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions.
4.1 JavaScript Introduction
Nguyen Ich Cuong.  Course duration: 45’  Purpose: Present Introduction to JQuery  Targeted attendees: NICorp Trainee  Tests/quiz: Yes - 10’
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
JavaScript & jQuery the missing manual Chapter 11
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript - A Web Script Language Fred Durao
Web Design: Basic to Advanced Techniques Fall 2010 Mondays 7-9pm 200 Sutardja-Dai Hall Introduction to PHP.
Web Development 101 Presented by John Valance
LOGO sparcs.org 1 jQuery Tutorial Presenter ㅎㅇㅎㅇ.
JavaScript Library. What is jQuery jQuery is a lightweight JavaScript library. The purpose is to make it easier to use JavaScript code on your website.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
JQuery and AJAX WEB Technologies : PHP Programming Language.
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
IS2802 Introduction to Multimedia Applications for Business Lecture 07: Introduction to jQuery Rob Gleasure
Unit 13 –JQuery Basics Instructor: Brent Presley.
Web Technologies Lecture 8 JQuery. “A fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax.
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.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
DOM & Jquery Nov. 09, Jquery JavaScript Library DOM (Document Object Model) HTML/XML/etc. Ajax (Asynchronous JavaScript and XML)
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Formatting HTML Links HTML Head HTML CSS HTML.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
JQuery.
Tutorial 10 Programming with JavaScript
AJAX and REST.
JQuery.
JQUERY Online TRAINING AT GOLOGICA
14 A Brief Look at JavaScript and jQuery.
Dynamic Web Pages (Flash, JavaScript)
JavaScript Introduction
JQuery with ASP.NET.
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Presentation transcript:

JavaScript, jQuery & AJAX

What is JavaScript? An interpreted programming language with object oriented capabilities. Not Java! –Originally called LiveScript, changed to JavaScript as a marketing ploy by Sun and Netscape. Can also be referred to as ECMAScript. Not simple! –Although it is loosely typed and can be used by web developers in a “cookbook” fashion (think image rollovers), JavaScript is a fully featured programming language with many advanced features.

Client Side JavaScript When JavaScript is embedded in a web browser, it is referred to as Client Side JavaScript. Contains an extended set of functionality to interface with the web browser DOM (Document Object Model). Objects, such as window and document, and functions, like event detection and handling, are included in Client Side JavaScript.

What is jQuery? A framework for Client Side JavaScript. Frameworks provide useful alternatives for common programming tasks, creating functionality which may not be available or cumbersome to use within a language. An open source project, maintained by a group of developers, with a very active support base and thorough, well written documentation.

What jQuery is not… A substitute for knowing JavaScript –jQuery is extraordinarily useful, but you should still know how JavaScript works and how to use it correctly. This means more than Googling a tutorial and calling yourself an expert. A solve all –There is still plenty of functionality built into JavaScript that should be utilized! Don’t turn every project into a quest to ‘jQuery-ize’ the problem, use jQuery where it makes sense. Create solutions in environments where they belong.

What is available with jQuery? Cross browser support and detection AJAX functions CSS functions DOM manipulation DOM transversal Attribute manipulation Event detection and handling JavaScript animation Hundreds of plugins for pre-built user interfaces, advanced animations, form validation, etc Expandable functionality using custom plugins Small foot print

jQuery Syntax $.func(…); or $(selector).func1(…).func2(…).funcN(…); jQuery Object, can be used instead of jQuery Selector syntax, many different selectors allowed Chainable, most functions return a jQuery object Function parameters $ selector func (…)

The jQuery/$ Object Represented by both $ and jQuery –To use jQuery only, use jQuery.noConflict(), for other frameworks that use $ By default, represents the jQuery object. When combined with a selector, can represent multiple DOM Elements, see next slide. Used with all jQuery functions.

jQuery Selectors $( html ) Create DOM elements on-the- fly from the provided String of raw HTML. $( elems ) Wrap jQuery functionality around single or multiple DOM Elements. $( fn ) A shorthand for $(document).ready(), allowing you to bind a function to be executed when the DOM document has finished loading. $( expr, context ) This function accepts a string containing a CSS or basic XPath selector which is then used to match a set of elements. Default context is document. Used most often for DOM transversal. Selectors will return a jQuery object, which can contain one or more elements, or contain no elements at all.

jQuery Selector Examples $( html ) –$(‘ Click here! ’) $ ( elems ) –$(document), $(window), $(this) –$(document.getElementsByTagName(“p”)) $ ( fn ) –$(function() { alert(“Hello, World!”) }); $ ( expr, context ) –$(“p”), $(“form”), $(“input”) –$(“p#content”), $(“#content”), $(“.brandnew”), $(“p span.brandnew:first-child, #content”) –$(“p/span”), $(p/span:first), $(p:first/span:even) $(“div:visible p[a]”) –var xml = ‘ One Two ’; $(“d it nm:contains(‘One’)”, xml),

jQuery Functions Attached to the jQuery object or chained off of a selector statement. Most functions return the jQuery object they were originally passed, so you can perform many actions in a single line. The same function can perform an entirely different action based on the number and type of parameters.

jQuery Usage Example Changed First item Second item Changed Third item First item Second item Third item Changed First item Second item Changed Third item $(“li:odd”).prepend(‘ Changed ’).css({background:“red”});

jQuery Usage Example Some text More text Some text More text Goodbye cruel world. Some text More text Goodbye cruel world. $(“div:hidden”).find(“.foo”).empty().text(“Changed”).end().show(); Some text More text Changed Some text More text Changed Some text More text Changed

jQuery Advanced Example Select All Select None Select All Select None $(“span.none”).click( function(){ $(this).siblings(“:checkbox”).removeAttr(“checked”); } ); $(“span.all”).click( function(){ $(this).siblings(“:checkbox”).attr(“checked”,“checked”); } ); $(“span”).click( function(){ if($(this).text()==“Select All”)) $(this).siblings(“:checkbox”).attr(“checked”,“checked”); else if ($(this).attr(“class”)==“none”) $(this).siblings(“:checkbox”).removeAttr(“checked”); } ); or

jQuery & AJAX jQuery has a series of functions which provide a common interface for AJAX, no matter what browser you are using. Most of the upper level AJAX functions have a common layout: –$.func(url[,params][,callback]), [ ] optional url: string representing server target params: names and values to send to server callback: function executed on successful communication.

jQuery AJAX Functions $.func(url[,params][,callback]) –$.get –$.getJSON –$.getIfModified –$.getScript –$.post $(selector), inject HTML –load –loadIfModified $(selector), ajaxSetup alts –ajaxComplete –ajaxError –ajaxSend –ajaxStart –ajaxStop –ajaxSuccess $.ajax, $.ajaxSetup –async –beforeSend –complete –contentType –data –dataType –error –global –ifModified –processData –success –timeout –type –url

jQuery AJAX Example AJAX Demo var cnt = 0; $(function(){ $.ajaxSettings({ error:function(){alert(“Communication error!”);} }); $(“:button”).click(function(){ var input = {in:$(“:textbox”).val(),count:cnt}; $.getJSON(“ajax.php”,input,function(json){ cnt = json.cnt; $(“.cnt”).text(cnt) $(“.msg”).text(json.out); }); Input: Output # : <?php $output = ‘’; switch($_REQUEST[‘in’]) { case ‘hello’: $output = ‘Hello back.’; break; case ‘foo’: $output = ‘Foo you, too.’; break; case ‘bar’: $output = ‘Where Andy Capp can be found.’; break; case ‘foobar’: $output = ‘This is German, right?’; break; default: $output = ‘Unrecognized string.’; } $count = $_REQUEST[‘count’]+1; echo json_encode( array( ‘out’ => $output, ‘cnt’ => $count ) ); exit; ?>

jQuery Demos demo ajax demo offer management (prototyping)offer management animation demo

jQuery Resources Project website – Learning Center – – – Support – – mailing list archivehttp:// –irc.freenode.net irc room: #jqueryirc.freenode.net Documentation – – – jQuery Success Stories –