With jQuery and AJAX Doncho Minkov Telerik Corporation www.telerik.com Technical Trainer.

Slides:



Advertisements
Similar presentations
REST Vs. SOAP.
Advertisements

SharePoint and Knockout for the REST of Us
Web Service Testing RESTful Web Services Snejina Lazarova Dimo Mitev
Overview of Twitter API Nathan Liu. Twitter API Essentials Twitter API is a Representational State Transfer(REST) style web services exposed over HTTP(S).
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
What are Web Services? How to use them?
With jQuery and AJAX Doncho Minkov Telerik Corporation Technical Trainer.
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Jon Flanders INT303. About Me  Jon Flanders –  Independent consultant/trainer  BizTalk MVP.
RSS RSS is a method that uses XML to distribute web content on one web site, to many other web sites. RSS allows fast browsing for news and updates.
More APIs: Web Services CMPT 281. Announcements Project milestone Lab: – Web services examples.
RSS Feeds in AquaBrowser Library Staff Training Upper Midwest Users Group Conference 18 October 2011 Nina Mentzel, SDLN
JavaScript & jQuery the missing manual Chapter 11
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQuery Web Services A web service is a software system that supports interaction (requesting data,
HTTP, AJAX and REST How HTTP and Web Services Work? SoftUni Team Technical Trainers Software University
Introducing Dreamweaver MX 2004
Tutorial 1 Getting Started with Adobe Dreamweaver CS3
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Google Data APIs Google Data APIs : Integrando suas aplicações Java com os serviços Google.
The New Zealand Institute for Plant & Food Research Limited Matthew Laurenson Web Services: Introduction & Design Considerations.
Twitter.  Twitter is a social networking and micro-blogging service that enables its users to send and read other user’s updates.
RESTful applications Norman White. REST Representational state transfer Key concepts – Client Server architecture built on transferring resources between.
HTML5. HTML5’s overall theme The browser as a rich application platform rich, cross-device user interfaces offline operation capability hardware access.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
Open Data Protocol * Han Wang 11/30/2012 *
Project “Astoria” first announced in Mix 2007 Shared early prototypes, got tons of feedback Now we’re talking about the real deal Production quality bits,
Or, Hey can’t we just do it using HTTP for the envelope?
Introduction to HTML. What is HTML?  Hyper Text Markup Language  Not a programming language but a markup language  Used for presentation and layout.
RESTful Web Service 2014 년 12 월 한연희
Wiki Space Introduction How to use Wiki spaces to complete your project on the Crusades.
Twitter 101. What is Twitter? Twitter is a social networking and micro-blogging service that enables its users to send and read other user’s updates.
HTML5 AND THE FUTURE JAVASCRIPT PLATFORM Marcelo Lopez Ruiz Senior Software Design Engineer Microsoft Corporation.
Google Data Protocol Guy Mark Lifshitz. Motivation Google’s Mission: – Organize the world’s information – Make information universally accessible – Provide.
Part 2 – WWW and HTTP Nikolay Kostov Telerik Corporation
API Crash Course CWU Startup Club. OUTLINE What is an API? Why are API’s useful? What is HTTP? JSON? XML? What is a RESTful API? How do we consume an.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Adding maps, widgets, searchbox Week 07 TCNJ Web 2 Jean Chu.
1 Alternative view on Internet Computing Web 1.0 –Web 1.0 is first generation, Web Information based. Driven by Information provider. Web 2.0 Ajax enabled.
Introduction to Web Services
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
RESTful Web Services What is RESTful?
RESTful Web Services A MIDAS MISSION PRESENTATION APRIL 29, 2015.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
CMS 2: Advanced Web Editing - Content Presented By: Katie Pagano, Special Projects Manager Steve Pont, Product Architect.
Virtual techdays INDIA │ November 2010 Integrating Social Networks with ASP.NET Krishna Chaitanya T │ Future Web Research Lab, SETLabs, Infosys WE.
© 2014 IBM Corporation Activity Streams Integration IBM Connections 5.0 Workshop Author: Paul Godby IBM Ecosystem Development Duration: 45 minutes.
COMP 143 Web Development with Adobe Dreamweaver CC.
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.
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
CSCI 3100 Tutorial 5 JavaScript & Ajax Jichuan Zeng Department of Computer Science and Engineering The Chinese University of Hong.
Embt.co/sprint-rest-json-services Blog Notes: Building RESTful servers. In C++ Builder Developer Skill Sprint Tips, Tricks and Techniques The Ultimate.
DOM, jQuery, AJAX, REST Using Kinvey as JS Back-End
National College of Science & Information Technology.
API (Application Program Interface)
RESTful Sevices Distributed Objects Presented by: Shivank Malik
Cosc 5/4730 REST services.
Connor Griesemer & Kevin Wu
Testing REST IPA using POSTMAN
WEB API.
$, $$, $$$ API testing Edition
Introduction to World Wide Web
WCF Data Services and Silverlight
NEECOM – May 22, 2019 Todd L Gould, CEO
Presentation transcript:

With jQuery and AJAX Doncho Minkov Telerik Corporation Technical Trainer

 RESTful Web Services  XML, JSON, RSS  Consuming REST with jQuery  Consuming Twitter REST with jQuery   Features  Facebook API

Lightweight Architecture for Web Services

"Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web."  Application state and functionality are resources  Every resource has an URI  All resources share a uniform interface  This natively maps to the HTTP protocol

 One URI for a resource, multiple operations  Add a new document "RestTalk" in category "Code"  PUT  Get the document / some page  GET  GET  Remove the document  DELETE  Retrieve metadata  HEAD 5

Comparing the Common Service Data Formats

 XML is markup-language for encoding documents in machine-readable form  Text-based format  Consists of tags, attributes and content  Provide data and meta-data in the same time 7 <library> HTML 5 Bay Ivan HTML 5 Bay Ivan WPF 4 Microsoft WPF 4 Microsoft WCF 4 Kaka Mara WCF 4 Kaka Mara UML 2.0 Bay Ali UML 2.0 Bay Ali </library>

 JSON (JavaScript Object Notation)  Standard for representing simple data structures and associative arrays  Lightweight text-based open standard  Derived from the JavaScript language 8 { "firstName": "John", "lastName": "Smith", "age": 25, "firstName": "John", "lastName": "Smith", "age": 25, "address": { "streetAddress": "33 Alex. Malinov Blvd.", "address": { "streetAddress": "33 Alex. Malinov Blvd.", "city": "Sofia", "postalCode": "10021" }, "city": "Sofia", "postalCode": "10021" }, "phoneNumber": [{ "type": "home", "number": " "}, "phoneNumber": [{ "type": "home", "number": " "}, { "type": "fax", "number": " " }] { "type": "fax", "number": " " }]}, { "firstName": "Bay", "lastName": "Ivan", "age": 79 }

 RSS (Really Simple Syndication)  Family of Web feed formats for publishing frequently updated works  E.g. blog entries, news headlines, videos, etc.  Based on XML, with standardized XSD schema  RSS documents (feeds) are list of items  Each containing title, author, publish date, summarized text, and metadata  Atom protocol aimed to enhance / replace RSS 9

10 <channel> W3Schools Home Page W3Schools Home Page Free web building tutorials Free web building tutorials RSS Tutorial RSS Tutorial New RSS tutorial on W3Schools New RSS tutorial on W3Schools XML Tutorial XML Tutorial New XML tutorial on W3Schools New XML tutorial on W3Schools </channel></rss>

How To Make It Work?

 Can be done with three methods  $.ajax(…)  $.get(…)  $.post(…)  $.get(…) and $.post(…) use $.ajax(…) under the hood  These methods load data from the server  Using rest service  Return JSON, Atom, RSS

$.ajax({ url: "RestService.svc/students/all", type: "GET", timeout: 5000, dataType: "json", success: function (students) { $('#loadStudentsButton').html("students loaded"); $('#loadStudentsButton').html("students loaded"); // do something with the students data // visualize them, etc… } error: function (err) { error: function (err) { $('#loadStudentsButton').html("error: " + err.status); $('#loadStudentsButton').html("error: " + err.status); }}); The path of the REST Service (should be on the same server) Request type ('GET' or 'POST') The type of data to expect(JSON,XML) In case the request is successful In case the request is unsuccessful  Example of jQuery.ajax(…) get request

$.ajax({ url: "RestService.svc/students/new", type: "POST", timeout: 5000, contentType: "application/json", data: JSON.stringify(student), success: function () { $('#createStudentButton').html("student created"); //reload the students }, error: function (err) { $('#createStudentButton').html("error: " + err.status); }}); The type of data to sent to the server (JSON, XML) We have a student object (in JSON) and should make it readable for the server  Example of jQuery.ajax(…) post request

Live Demo

Lets Make Our Own Twitter?

 First lets get familiar with the Twitter REST API  We are given a set of methods to  Get a number of tweets for a given user  Post a tweet using jQuery  Search tweets  Etc…  First need to register a twitter app

 Registering a Twitter App  Go to  Register a App  When your app is registered you get:  Consumer key  The key your app authorizes with  Consumer secret  Used for user authentication

 GET statuses/user_timeline  Returns the 20 most recent statuses posted by the authenticating user  It is also possible to request another user's timeline by using  The screen_name or user_id parameter  The other users timeline will only be visible if they are not protected  If the authenticating user's follow request was

$.ajax({ url : user+".json?callback=?" dataType : "json", timeout:5000, success : function(data) { //Visualize Tweets }, error : function() { //Visualize Errors //Visualize Errors},});  Getting Tweets from Twitter with jQuery

Live Demo

How To Make It Easy?

 What is  An easy-to-deploy solution  Bringing the Twitter communication platform  Promotes a more engaged user base  Can be used to add  Follow Buttons, Hovercards, linkify Twitter usernames  Build integrations with "Connect to Twitter"

 With a registered App at dev.twitter.com dev.twitter.com  You get a AppId  In the head part of the app include  With anywhere.js included  A twttr object and an anywhere function  Used to make the magic with anywhere

Live Demos

new TWTR.Widget({ version: 2, type: 'search', search:, interval: 300, version: 2, type: 'search', search:, interval: 300, title: 'It\'s a double rainbow', subject: 'Across the sky', title: 'It\'s a double rainbow', subject: 'Across the sky', width: 250, height: 300, width: 250, height: 300, theme: { theme: { shell: {background:'# 70fd90 ',color: '# '}, shell: {background:'# 70fd90 ',color: '# '}, tweets: {background: '# c6fec7 ', color: '# ', links: '# 1985b5 '} tweets: {background: '# c6fec7 ', color: '# ', links: '# 1985b5 '}}, features: { scrollbar: true, loop: true, live: true, behavior: 'default' }}).render().start();

new TWTR.Widget({ version: 2, type: 'profile', search:, interval: 300, version: 2, type: 'profile', search:, interval: 300, title: 'It\'s a double rainbow', subject: 'Across the sky', title: 'It\'s a double rainbow', subject: 'Across the sky', width: 250, height: 300, width: 250, height: 300, theme: { theme: { shell: {background:'# 70fd90 ',color: '# '}, shell: {background:'# 70fd90 ',color: '# '}, tweets: {background: '# c6fec7 ', color: '# ', links: '# 1985b5 '} tweets: {background: '# c6fec7 ', color: '# ', links: '# 1985b5 '}}, features: { scrollbar: true, loop: true, live: true, behavior: 'default' }}).render().start();

Live Demo

Login/Logout, Tweet, etc.

twttr.anywhere(function (T) { T("#login").connectButton({ authComplete: function(user) { authComplete: function(user) { //something to do after authentication }, },});});  Login: function logOut() { twttr.anywhere.signOut(); twttr.anywhere.signOut(); }  Logout

Live Demo

 Tweet Box twttr.anywhere(function (T) { T("#tbox").tweetBox(); T("#tbox").tweetBox();});  Follow Button twttr.anywhere(function (T) { T('#follow-donchominkov').followButton("donchominkov"); T('#follow-donchominkov').followButton("donchominkov");});

Live Demo

Lets Play a Little with Facebook

 Facebook provides a SDK for JavaScript  To use the functionality of Facebook  Should register an app  Through phone number  With credit card  Absolutely free  Made for precautions

Live Demo

Questions?