Category Archives: ajax

Autocompletamento con php e ajax

In questo tutorial vedremo come realizzare uno script per l'autocompletamento in ajax che prende i valori da un database

Come prima cosa dobbiamo scaricare l'ultima versione della libreria javascript script.a.culos qui 

Scarichiamo e mettiamo come codice

<script language="JavaScript" SRC="lib/prototype.js"></script>
<script language="Javascript" src="javascript/scriptaculous.js"> </script>
<script language="Javascript" src="javascript/effects.js"> </script>
<script language="Javascript" src="javascript/controls.js"> </script> 

Inserite le librerie necessarie al funzionamento dello script, inseriamo la parte di codice che gestisce il campo da autocompletare

<input type="text" id="search" name="search" />
<div id="hint"></div>
<script type="text/javascript">   
new Ajax.Autocompleter("search","hint","fillfield.php");
</script>

Il file fillfield.php è il file che mostrerà tutte le possibili parole che possono essere utili al completamento del campo

<?php
// cambia le impostazioni per la connessione al db:
  $host = "localhost";
  $database = "";
  $user = "";
  $password = "";
// connettiti al db e cerca le parole
  mysql_connect($host,$user,$password);
  mysql_select_db($database);
  $sql = "SELECT title FROM tabella WHERE title LIKE '%" . $_POST['search'] . "%'";
  $resource = mysql_query($sql);
?>
<ul>
<? while($taken = mysql_fetch_assoc($resource)) { ?>
  <li><? echo stripslashes($taken['title']);?></li>
<? } ?>
</ul> 

Una serie di links a video tutorials

The JavaScript Programming Language (by Douglas Crockford)
Yahoo! JavaScript Architect Douglas Crockford provides a comprehensive introduction to the JavaScript Programming Language in this four-part video:

  • JavaScript Video Lecture Part I (Yahoo Video)
    JavaScript, aka Mocha, aka LiveScript, aka JScript, aka ECMAScript, is one of the world's most popular programming languages. Virtually every personal computer in the world has at least one JavaScript interpreter installed on it and in active use. JavaScript's popularity is due entirely to its role as the scripting language of the WWW. Despite its popularity, few know that JavaScript is a very nice dynamic object-oriented general-purpose programming language. How can this be a secret? Why is this language so misunderstood?
  • JavaScript Video Lecture Part II
    JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.

  • JavaScript Video Lecture Part III
    Nearly all of the books about JavaScript are quite awful. They contain errors, poor examples, and promote bad practices. Important features of the language are often explained poorly, or left out entirely. I have reviewed dozens of JavaScript books, and I can only recommend one: JavaScript: The Definitive Guide (5th Edition) by David Flanagan.

  • JavaScript Video Lecture Part IV
    Most of the people writing in JavaScript are not programmers. They lack the training and discipline to write good programs. JavaScript has so much expressive power that they are able to do useful things in it, anyway. This has given JavaScript a reputation of being strictly for the amateurs, that it is not suitable for professional programming. This is simply not the case.

  • Lecture Slides (zipped pdf)

Advanced JavaScript (by Douglas Crockford)
Yahoo! JavaScript Architect Douglas Crockford lectures on the nuances of the JavaScript programming language in this three-part video:

  • Advanced JS Part I (Yahoo Video)
    Douglas Crockford teaches "Advanced JavaScript." This course is broken into three clips; this is the first of those three clips. Note that when Douglas begins the talk referring to the "third installment", he's referring to "Advanced JavaScript" being the third class in a series; this is indeed the first of the three clips comprising the "Advanced JavaScript" class.

  • Advanced JS Part II
    No programming language is perfect. JavaScript has its share of design errors, such as the overloading of + to mean both addition and concatenation with type coercion, and the error-prone with statement should be avoided. The reserved word policies are much too strict. Semicolon insertion was a huge mistake, as was the notation for literal regular expressions. These mistakes have led to programming errors, and called the design of the language as a whole into question.

  • Advanced JS Part III
    The official specification for the language is published by ECMA. The specification is of extremely poor quality. It is difficult to read and very difficult to understand. This has been a contributor to the Bad Book problem because authors have been unable to use the standard document to improve their own understanding of the language. ECMA and the TC39 committee should be deeply embarrassed.

  • Lecture Slides

Advanced JavaScript with Libraries (by John Resig)
John Resig of Mozilla Corp., author of the popular JQuery JavaScript library, describes the role of libraries in the world of frontend engineering, the problems they solve, and the things we can learn from how developers use and think about libraries in their projects.

Maintainable JavaScript (by Nicholas Zakas)
Nicholas Zakas is an engineer on the team that brings you My Yahoo!, one of the most popular personalized portals on the web. In this talk, Zakas focuses on some fundamental concepts in the world of frontend engineering with an eye toward making code more maintainable.

An Inconvenient API: The Theory of the DOM [Document Object Model] (by Douglas Crockford)
Yahoo! JavaScript Architect Douglas Crockford discusses the nexus between JavaScript and the browser, exploring the history of the BOM and DOM APIs and their impact on frontend engineering today. This presentation is archived in three parts:

Welcome to FireBug 1.0 (by John Hewitt)
Joe Hewitt is a Mozilla developer who has written software dear to the heart of all web developers, including the original Mozilla DOM Inspector. Joe's newest Mozilla tool is Firebug, an integral logging and debugging extension for Firefox that sets a new standard for its category. Joe provided a power-user tour while announcing Firebug 1.0's release on January 25, 2007, at Yahoo!.

New Features in the Next C++ Standard

The upcoming C++ standard will have many new features, several major and many minor. The major features are concurrency, template concepts, move semantics, generalized constant expressions, automatic variable typing, and garbage collection. We will present an overview of the major features and breeze through a list of other features, commenting on their likeliness to make the standard.

Advanced Python (Or Understanding Python)

The Python language, while object-oriented, is fundamentally different from both C++ and Java. The dynamic and introspective nature of Python allow for language mechanics unlike that of static languages. This talk aims to enlighten programmers new to Python about these fundamentals, the language mechanics that flow from them and how to effectively put those to use. Among the topics covered are duck-typing, interfaces, descriptors, decorators, metaclasses, reference-counting and the cyclic-garbage collector, the divide between C/C++ data and Python objects and the CPython implementation in general.

This talk is part of the Advanced Topics in Programming Languages series. The goal of this series is to encourage all of the people at Google who know and love programming languages to share their knowledge.

Python Design Patterns (by Alex Martelli)

Design Patterns must be studied in the context on the language in which they'll get implemented (the Gang of Four made that point very strongly in their book, though almost everybody else seems not to have noticed :-). This talk explores several categories of classic "elementary" DPs in a Python context -- Creational, Masquerading, Adaptation, and Template.

Learning Java Programming - Video Tutorial

Delphi Training Series: Programming 101 (by 3DBuzz)
Ever wanted to become a programmer? The Delphi Training Series: Programming 101 is a sequence of training videos designed to teach the complete beginner how to become a programmer using Delphi.

  • Dephi Programming Episode 1 (YouTube video)
    In this episode, the viewer is shown where they can download the free Integrated Development Environment (IDE) known as Turbo Delphi, as well as how to get it installed and registered. Once launched the video will walk the viewer through the creation of their first simple program.
  • Dephi Programming Episode 2
  • Dephi Programming Episode 3
    Episode 3 explores simple game design!

  • Dephi Programming Episode 4
    In this episode, the viewer is introduced to the concept of variables.
    This video is the first in a mini-series aimed at the creation of your own MP3 player.

  • Dephi Programming Episode 5
    In this episode, the viewer is exposed to the world of Procedures and Functions.
    This video continues the series with focus on writing your own mp3 player.

  • Dephi Programming Episode 6
    In this episode, the viewer is presented with lecture covering DLLs, handles, the BASS library, and all steps required to write the foundation of a simple MP3 player.

  • Dephi Programming Episode 7
  • Dephi Programming Episode 8
    In the eighth installment of the Delphi Training Series, we take a short break away from the MP3 player we were writing to introduce you to a new aspect of programming: The IF statement.

  • Dephi Programming Episode 9
    The ninth episode of the Delphi Training Series is another theory-driven exploration, stepping away from the MP3 player to take a look at looping and how it works inside of Object Pascal.

Vim: 7 Habits For Effective Text Editing (by Bram Moolenaar)

A large percentage of time behind the computer screen is spent on editing text. Investing a little time in learning more efficient ways to use a text editor pays itself back fairly quickly. This presentation will give an overview of the large number of ways of using Vim in a smart way to edit programs, structured text and documentation. Examples will be used to make clear how learning a limited number of habits will avoid wasting time and lower the number of mistakes. Bram Moolenaar is mostly known for being the benevolent dictator of the text editor Vim. His roots are in electrical engineering and for a long time he worked on inventing image processing algorithms and software for big photo copying machines. At some point his work on Open-Source software became more important, making the development of Vim his full time job. He also did the A-A-P project in between Vim version 6.0 and 7.0. Now he works for Google in Zurich, still improving Vim on the side.

Bonus Lecture this Month:
An Introduction to SQLite (by Richard Hipp)

SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine. SQLite implements a large subset of SQL-92 and stores a complete database in a single disk file. The library footprint is less than 250 KB making is suitable for use in embedded devices and applications where memory space is scarce.

This talk provides a quick overview of SQLite, its history, its strengths and weaknesses, and describes situations where it is much more useful than a traditional client/server database. The talk concludes with a discussion of the lessons learned from the development of SQLite and how those lessons can be applied to other projects.

Tutorials su ajax


Getting Started  

  1. An Ajax Hello World project to Get You Going : First program at Mike On Code   
  2. Rasmus 30 second AJAX Tutorial : first program using Ajax at CoderLab   
  3. Instant Tutorial : Quick tutorial at AleemBawany   
  4. Ajax Toybox : Simple first programs including, Hello, World, Dynamic City, State Lookup, Ajax to Clean Your Clock, Ajax Calculator and an RSS News Ticker.   
  5. A simple Ajax example : a simple program demo for Ajax at MD Groves   
  6. Ajax Toolbox / XMLHttpRequest AjaxRequest Library Examples : Ajax examples including Error Handling, Time Out, Simultaneous Requests, Activity Monitoring, Form Submittal, Event Handlers, Queued Requests, Request Parameters   
  7. An Introduction to Ajax : introduction to Ajax at Prokata   
  8. Implementing simple Ajax interaction in your Web Application using XMLHttpRequest object : Intro + explanatory diagram at JavaReference   
  9. Nitty Gritty Ajax : Intro and Tutorial at WebMonkey   
  10. A List Apart: Articles: Getting Started with Ajax : An excellent intro ; Chapter 27 of Web Design in a Nutshell at A List Apart   
  11. Ajax Beginners Tutorial : Intro at AjaxProjects   
  12. Guide to Using XMLHttpRequest : Using XMLHttpRequest with PHP and MySQL at WebPasties   
  13. Ajax : Tutorial at YourHTMLSource   
  14. Javascript Remote Scripting with PHP : Tutorial at SimpleTutorials   
  15. How To: Learn AJAX in 20 minutes : Intro at Sematopia   
  16. Take Command with Ajax : Intro tutorial; at SitePoint   
  17. Ajax Tutorial : Ajax tutorial at W3Schools.com   
  18. Ajax Tutorial : at Tizag.com   
  19. Ajax Hello World : at Jot.com   
  20. Fundations of Ajax (PDF : by Ryan Asleson   
  21. All Request, All The Time : XMLHttpRequest explanation at WebMonkey   
  22. Very Dynamic Web Interfaces via Ajax : at XML.com   
  23. A Simpler Ajax Path : at OnLamp   
  24. Alternate Ajax Techniques, Part 1 : Detailed intro at WebReference   
  25. Ajax:Getting Started : Long intro at Mozilla Developer Center   
  26. Dynamical HTML and XML: The XMLHttpRequest Object : at Apple.com   
  27. Mastering Ajax Part 1 : Introduction to Ajax : at IBM   
  28. Mastering Ajax Part 2 : Make asynchronous requests with JavaScript and Ajax : at IBM   
  29. Mastering Ajax Part 3 : Advanced requests and responses in Ajax : at IBM   
  30. Mastering Ajax Part 4: Exploiting DOM for Web response : at IBM   
  31. How to Develop Web Applications with Ajax, Pt. 1 : App Development Series at WebReference   
  32. How to Develop Web Applications with Ajax: Pt. 2 : App Development Series at WebReference   
  33. Developing Web Applications with Ajax, Pt. 3 : App Development Series at WebReference   
  34. Ajax Workshop 1: Ajax basics & building a simple email verification with prototype.js. : at AjaxLessons   
  35. Ajax Workshop 2: Building Tabbed Content : at AjaxLessons   
  36. Ajax Workshop 3: Shopping Cart using Script.aculo.us : at AjaxLessons   
  37. Ajax Workshop 4: Live Data with JSON & Prototype.js : at AjaxLessons   
  38. AJAX Was Here - Part 1: Client Side Framework : at CodeProject   
  39. AJAX Was Here - Part 2: ASP.NET Integration : at CodeProject   
  40. AJAX WAS Here - Part 3 : Auto Complete TextBox : at CodeProject   
  41. Step by Step to AJAX : at DevArticles   
  42. The AJAX Revolution. Join in. : Five-part detailed tutorial ; at telerik.com   
  43. Very Dynamic Web Interfaces : at XML.com   
  44. Ajax from Scratch: Implementing Mutual Exclusion in JavaScript : Basic tutorial at Developer   
  45. AdvancedAJAX 1.1 : at Anakin    

Bookmarklets   

  1. Creating Huge Bookmarklets : Create bookmarklets; bypass various bytes/characters/size restrictions.    

Chat

       
  1. Ajax Chat Sources Code for Download : chat using PHP and MySQL   
  2. Building an AJAX-Based Chat: The Barebones Structure : at DevArticles   
  3. Lace - Ajax Chat : free web chat application ;demo; download.   
  4. Most Simple Ajax Chat Ever : at LinuxUser.at    

Drag and Drop   

  1. Drag & Drop Sortable Lists with JavaScript and CSS : sorting for lists and sorting in two dimensions   
  2. Easy Ajax in symfony : creates a drg-and-drop shopping cart; with demo   
  3. Building a Drag-and-Drop Shopping Cart with Ajax : at Sys-Con Brasil   
  4. Scriptaculous Lists with PHP : drag-and-drop at GregPhoto   
  5. Fun with Drag and Drop with RICO : drag-and-drop with RICO demo   
  6. Rico Drag n'Drop p2: Rico.Draggable : drag-and-drop with RICO details   

Dynamically Content Loading   

  1. Ajax Dynamic Content : at DHTMLGoodies   
  2. Dynamically loaded articles : at DHTMLGoodies    

Forms and Autocomplete   

  1. Accessible Forms and Unobtrusive Javascript : at DotVoid   
  2. Submit a form with Ajax : at CakeBaker   
  3. Niceforms : at BadBoy   
  4. Alter data with Ajax forms : at Symphony-Project   
  5. Ajax Dynamic List : at DHTMLGoodies   
  6. Chained Select Boxes : at DHTMLGoodies   
  7. Dynamic Client Lookup : at DHTMLGoodies    

File Uploader   

  1. Better File Uploads with Ajax and JavaServer Faces : file upload with progress-bar; at Java.net    

Image/Display/Edit/Gallery/Lightbox/Slideshow

       
  1. Prototype Javascript Lightboxes : window on any page; at Xilinus   
  2. Lightbox JS : at HuddleTogether   
  3. Lightbox Gone Wild : at ParticleTree   
  4. Building aB: Customizing Lightbox : at AlwaysBeta   
  5. Ajax: What is it Good For? : Ajax powered Fading Image Gallery at DHTML Nirvana.   
  6. minishowcase : simple php/javascript online photo gallery, powered by AJAX/JSON at frwrd   
  7. Zen Photo : a simpler web photo album   
  8. Ajax Image Gallery : ajax gallery demo at StrangerThanFiction   
  9. Ajax Image Gallery : A very basic Ajax image gallery example   
  10. S5: A Simple Standards-Based Slide Show System : at MeyerWeb   
  11. Ajax-S : at RobertNyman   
  12. Slide Show with Controls : at Zapatec   
  13. Miniature slideshow for DIVs using Scriptaculous : at BigBold   
  14. Ajax flickr Slideshow : at Fettig   
  15. Live Thumbnails: Watch em Grow : at WebMonkey   
  16. Canvas Reflection Demo : at NeonDragon   
  17. iPhoto-like image resizing using Javascript : at AgilePartners   
  18. Ajax Banner Rotation : PHPied   
  19. Image crop - DHTML user interfaceat DHTMLGoodies  

  Keyword Suggest

       
  1. Creating an Autosuggest Textbox with JavaScript, Part 1 : at WebReference   
  2. Creating an Autosuggest Textbox with JavaScript, Part 2 : at WebReference   
  3. Creating an Autosuggest Textbox with JavaScript, Part 3 : at WebReference   
  4. How to create the Google Suggest feature with ASP.NET 2.0 : at DotNetJunkies  

  Live Search 

  1. HOWTO: Animated Live Search / Ordered List : at OrderedList   
  2. Live search explained : at JustAddWater  

  Misc/General 

  1. Ajax Using ASP.NET 1.1 : Ajax and ASP.NET; at AjaxProjects   
  2. What Is Ajax? : Ajax and ColdFusion ; at Sys-Con   
  3. Kick-start your Java apps : Ajax and Java : at IBM   
  4. Ajax for Java developers: Build dynamic Java applications : at IBM   
  5. AJAX: Asynchronous Java + XML? : at Developer.com   
  6. Kick-start your Java apps, Part 2 : Ajax and Java : at IBM   
  7. AJAX in action : Ajax and Java Technology : 15-minute video on AJAX and Java technology at Sun.com   
  8. Using JavaServer Faces Technology with AJAX : at Java.net   
  9. Ajax using XMLHttpRequest and Struts/ : by Frank Zammetti   
  10. Building a Shelf in WordPress : More-tab-slideout-area tutorial; at Asymptomatic   
  11. A Tale of Two IFrames or, How To Control Your Browsers History : iframes tutorial; at CodingParadise   
  12. Saving Session Across Page Loads Without Cookies, On The Client Side : saving state tutorial; at CodingParadise   
  13. Simple Ajax Functions - Snippets : common functions; at AjaxTutorial   
  14. Building a Spy : Digg Spy tutorial ; at StromCode   
  15. Create Your Own Ajax Effects : animated text; at ThinkVitamin   
  16. XMLHttpRequest Tracing for Ajax debugging : Ajax Debugger  

  Progress Bars 

  1. CakeTimer - An Ajax File Uploads Progress Bar : This is a demonstration of an Ajax powered progressbar to monitor file uploads with (Cake)PHP.  

  Rounded Corner    

  1. Rico rounded corners without all of Rico : at encytemedia  

  RSS

       
  1. RSS Ticker with Ajax feed ticker; : at AjaxProjects   
  2. Simple Ajax RSS ticker script : feed ticker; at DHTMGoodies   
  3. Slide In RSS items : feed slide in animation; at DHTMGoodies   
  4. Dragable RSS boxes : drag-and-drop boxes; at DHTMGoodies   
  5. Ajax RSS reader : at IBM  

  Shopping Cart   

  1. Flexstore on Rails Tutorial : by Christophe Coenraets   
  2. Fly to basket : shopping cart; at DHTMGoodies  

  Lists/Sorting

  1. How to Make Sortable Lists : lists and drag-and-drop- tutorial; at Symphony-Projects   
  2. Creating sortable lists with PHP and Ajax : at PHPRiot   
  3. Make all your tables sortable : at Kryogenix  

  Tabbed Pages  

  1. Building Tabbed Content : at AjaxLessons   
  2. Ajax Design Patterns : at Snyke  

  Trees    

  1. List based folder tree : at DHTMLGoodies   
  2. Update a tree with Ajax : at DHTMLGoodies    

Username Availability    

  1. Ajax username availability checking : check username ; at MDGroves  

  Voting     

  1. Ajax Poller : at DHTMLGoodies   
  2. Digg-like Ajax Voting : at Symphony-Project  

Login con php e ajax

In questo articolo vedremo come creare un sistema per creare un sistema di login sicuro usando XMLHttpRequest. Questo esempio è un sistema per il login che nn richiede il refresh della pagina ma veramente sicuro.

Vantaggi
User does not need to refresh the page to login.
User is notified instantly on incorrect username/password combination.
Overall user experience is more seamless.
Password is not sent in plain text ever (more secure than traditional system).
Javascript convenience with server-side security (uses PHP/MySQL).
Uses one-time use random seed to hash the password before sending (making interceptions useless).

Svantaggi
System is more prone to brute force attacks.
Can be minimized by adding a delay after a certain number of attempts per username or per client.
User may expect a login button.
One could still be added without reloading the page.
Older versions of Safari cannot disable a password field.
This code uses the MD5 encryption algorithm, which has since been proven to be less secure than previously thought. If you use this code, I strongly recommend you switch to a more secure encryption algorithm, such as SHA-1. For sites were security is not crucial, MD5 should suffice. 

Sito web: http://www.jamesdam.com/ajax_login/login.html 

Transizione per effetti di animazione

The first most common mistake is to do all animation effects at a constant speed. For many types of effects, linear/constant speed animation looks clunky because the animation starts and stops and so abruptly. The solution is to adjust the speed of the animation based on a sinusoidal curve rather than a line so that the transition looks smoother -- basically, it should start slow and end slow and speed up in the middle.

The second most common mistake is to do all animation at a constant frame rate. Given the dramatic DOM performance differences between web browsers and operating systems, an animation with a constant number of frames can take an order of magnitude longer on some users' computers. The solution is to perform animation in a constant amount of time, adjusting the frame rate based on the performance of the user's browser.

The Transition class below is a recipe that can handle any type of animation (linear, sinusoidal, etc) with a variable frame rate:

function Transition(curve, milliseconds, callback) {
    this.curve_ = curve;
    this.milliseconds_ = milliseconds;
    this.callback_ = callback;
    this.start_ = new Date().getTime();
    var self = this;
    this.runCallback_ = function() {
        self.run();
    };
}
Transition.prototype.run = function() {
    if (!this.hasNext()) return;
    this.callback_(this.next());
    setTimeout(this.runCallback_, 10);
}
Transition.prototype.hasNext = function() {
    if (this.done_) return this.oneLeft_;
    var now = new Date().getTime();
    if ((now - this.start_) > this.milliseconds_) {
        this.done_ = true;
        this.oneLeft_ = true;
    }
    return true;
}
Transition.prototype.next = function() {
    this.oneLeft_ = false;
    var now = new Date().getTime();
    var percentage = Math.min(1, (now - this.start_) / this.milliseconds_);
    return this.curve_(percentage);
}

The Transition class is designed to be used with a function that defines the curve/speed of the animation. Here are sinusoidal and linear examples:

 

function SineCurve(percentage) {
    return (1 - Math.cos(percentage * Math.PI)) / 2;
}
function LinearCurve(percentage) {
    return percentage;
}

You can use one of the functions with the Transition class with the following pattern:

var transition = new Transition(SineCurve, 1000, function(percentage) {
    // Move your element percentage of the way through the animation
});
transition.run();Here is a practical example that moves text diagonally across the screen at a sinuoidal speed:
var element = document.getElementById("animated");
element.style.position = "absolute";
element.style.left = "0px";
element.style.top = "0px";
var transition = new Transition(SineCurve, 1000, function(percentage) {
    var x = element.parentNode.offsetWidth - element.offsetWidth;
    var y = element.parentNode.offsetHeight - element.offsetHeight;
    element.style.left = Math.round(percentage * x) + "px";
    element.style.top = Math.round(percentage * y) + "px";
});
transition.run();

Fonte: http://ajaxcookbook.org/transitions-animation-effects/

PHP AJAX asynchronous file upload

L'upload di file asynchrono è uno delle richieste maggiori nelle applicazioni web basate su ajax. La classe standard di AJAX (XmlHttpRequest) non ha la capacità di processare p inviare file da una finestra di dialogo (input type="file"). Questo articolo contiene un esempio du applicazione (trivial file-sharing service, come rapidshare, megaupload o yousendit) che usa embedded frames (IFRAME) per l'upload di file. Mentre un file è uplodato nel frame hidden ,l'utente puo accedere ala pagina web.

http://www.anyexample.com/programming/php/php_ajax_example__asynchronous_file_upload.xml

Eventi javascript usati con ajax

  • onabort Occurs when the user aborts an action
  • onblur Occurs when an element loses the input focus
  • onchange Occurs when data in a control, such as a text field,changes
  • onclick Occurs when the user clicks an element
  • ondblclick Occurs when the user double-clicks an element
  • ondragdrop Occurs when the user drags and drops an element
  • onerror Occurs when there’s been a JavaScript error
  • onfocus Occurs when an element gets the focus
  • onkeydown Occurs when the user presses down on a key
  • onkeypress Occurs when the user presses a key
  • onkeyup Occurs when the user releases a key
  • onload Occurs when the page loads
  • onmousedown Occurs when the user presses down a mouse button
  • onmousemove Occurs when the user moves the mouse
  • onmouseout Occurs when the user moves the cursor away from an element
  • onmouseover Occurs when the user moves the cursor over an element
  • onmouseup Occurs when the user releases a mouse button
  • onreset Occurs when the user clicks a Reset button
  • onresize Occurs when the user resizes an element or page
  • onsubmit Occurs when the user clicks a Submit button
  • onunload Occurs when the browser unloads a page and moves to another page

Le proprieta dell’oggetto XMLHttpRequest

• onreadystatechange
– Event handler that fires at each state change
– You implement your own function that handles this
• readyState – sato corrente della richiesta
– 0 = uninitialized
– 1 = loading
– 2 = loaded
– 3 = interactive (some data has been returned)
– 4 = complete
• status
– HTTP Status ritornato dal server: 200 = OK
• responseText
– String version dei dati ritornati dal server
• responseXML
– XML DOM document dei dati ritornati
• statusText
– Testo dello status ritornato dal server