Showing posts with label How-To. Show all posts
Showing posts with label How-To. Show all posts

How To: Upload Files in Java using Ajax


Introduction


Browser-based file uploads, in particular those involving the HTML <input type="file"> tag, have always been rather lacking. As I am sure most of you are aware, uploading files exceeding 10MB often causes a very poor user experience. Once a user submits the file, the browser will appear to be inactive while it attempts to upload the file to the server.

While this happening in the background, many impatient users would start to assume that the server is "hanging" and would try to submit the file again. This of course, only helps to make matters worse.

In an attempt to make uploading of files more user-friendly, many sites display an indeterminate progress animation (such as a rotating icon) once the user submits the file. Although this technique may be useful in keeping the user distracted while the upload being submitted to the server, it offers very little information on the status of the file upload.

Another attempt at solving the problem is to implement an applet that uploads the file to the server through FTP. The drawback with this solution is that it limits your audience to those that have a Java-enabled browser.

How To: Submit Form using Ajax

The new release of CakePHP (RC2) comes with a completely rewritten AjaxHelper::form() function (with the disadvantage that it breaks existing code). Let’s look how to use it:

$ajax->form(array('action' => '/controller/action'), 'post',
array('update' => 'mydiv'));

I think this code is self-explanatory (if not, please write a comment). What’s cool about this code is the fact that it will also work when you disable JavaScript. The form will submit the form data in both cases to /controller/action.

That means you have to distinguish in your action whether it is called via Ajax or not, and then you have at least to select the appropriate layout. You can do it in the following way (thanks to nate for this hint):

Continue Reading the Tutorial

How To: Learn AJAX in 20 minutes

How To: Learn AJAX in 20 minutes

Here is a quick overview and example of AJAX in action. Before you begin, this example will only work in FireFox work in FireFox and IE7. You’ll have to change few things in the JavaScript for it to work in IE6. To download the files used below click here.

If you don’t have PHP/Apache installed, follow the tutorial I made to install it. The example below assumes you know the basics of PHP, you can learn as you go along if you don’t. A good reference is the base PHP website.

AJAX stands for Asynchronous JavaScript and XML. Conventional web application trasmit information to and from the sever using synchronous requests. This means you fill out a form, hit submit, and get directed to a new page with new information from the server.

With AJAX when submit is pressed, JavaScript will make a request to the server, interpret the results and update the current screen. In the purest sense, the user would never know that anything was even transmitted to the server.

Continue Reading The Article

What The Hell Is Ajax? For Non-Techies!!!!

Introduction

Have you wondered what AJAX is, and whether you should learn to apply it in your web development work? You’ve probably heard the buzzword, but what exactly makes AJAX tick? Let’s take a look “under the hood” and see just what the buzz is all about.

What is AJAX?

AJAX is an acronym for Asynchronous JavaScript and XML. It is a development technique for creating interactive web applications. Unlike classic web pages, which must load in their entirety if content changes, AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes.

What Does Ajax Uses?

1. CSS, for marking up and styling information.

2. The Document Object Model accessed with a client-side scripting language like JavaScript to dynamically display and interact with the information presented.

3. The XMLHttpRequest object to exchange data asynchronously with the web server.

4. XML is sometimes used as the format for transferring data between the server and client, although any format will work.

Continue Reading The Tutorial

How to make Username Avaialable or not checking Script using Ajax?

How to make Username Avaialable or not checking Script using Ajax?

The goal of this AJAX example is to allow a user who is registering for your site to see if the username they want to use is taken already or not, without having to submit a form and reload the page.

Read the complete tutorial
AJAX username availability checking

How to Make Sortable Tables using Ajax???/

How to Make Sortable Tables using Ajax???

Read the tutorial and check for yourself.

Sorttable: Make all your tables sortable
While the web design community gradually moves away from using tables to lay out the structure of a page, tables really do have a vital use, their original use; they're for laying out tabular data.

Best Collection of Tutorials for Ajax Begineers and Newbies!!!!

Best Collection of Tutorials for Ajax Begineers and Newbies!!!!

An Introduction to AJAX
A very nice introduction to AJAX.

Nitty Gritty Ajax
In the course of this tutorial, we're going to look at what Ajax can do. Then we'll use a JavaScript class to simplify your first steps toward the ultimate in speedy user interactivity.

A simple AJAX example
Based on Rasmus's 30 second AJAX tutorial, I've cobbled together a very rudimentary example of one approach to AJAX programming. A "Hello, World" AJAX program, if you will. You can view the demo here on my site, and download the source code (document attachment at the bottom of this article).

A List Apart: Articles: Getting Started with Ajax
The start of 2005 saw the rise of a relatively new technology, dubbed "Ajax" by Jesse James Garrett of Adaptive Path. Ajax stands for Asynchronous JavaScript and XML. In a nutshell, it is the use of the nonstandard XMLHttpRequest() object to communicate with server-side scripts.

Ajax Toybox
Justin has put together a nice group of AJAX tutorials including, Hello, World, Dynamic City, State Lookup, Ajax to Clean Your Clock, Ajax Calculator and an RSS News Ticker.

Introduction to Ajax
When it comes to Ajax, the reality is that it involves a lot of technologies -- to get beyond the basics, you need to drill down into several different technologies (which is why I'll spend the first several articles in this series breaking apart each one of them).

Ajax Toolbox / XMLHttpRequest AjaxRequest Library Examples
A great group of AJAX examples.

Rasmus' 30 second AJAX Tutorial
I find a lot of this AJAX stuff a bit of a hype. Lots of people have been using similar things long before it became "AJAX". And it really isn't as complicated as a lot of people make it out to be. Here is a simple example from one of my apps.

An Ajax "Hello World" project to Get You Going
Sometimes we all want something very simple to build a thorough understanding of the mechanics of a new technique before we dive into the deeper water beyond. Now, if you are into ASP.NET and not PHP you might like to take a look at my version of this ultra-simple introduction to Ajax with sincere thanks to the original author.

Ajax Beginners Tutorial
In this tutorial we'll discuss the basic principles of remote scripting using Ajax, a combination of javascript and XML to allow web pages to be updated with new information from the server, without the user having to wait for a page refresh.

I hope you find these links useful. Please drop in your comments.

Collection of Best Ajax Based Tutorials

Collection of Best Ajax Based Tutorials

Contains scripts from building a Spy, Building Shelf in wordpress, Cookies, Simple Ajax Code and Snippets, Ajax using ASP.NET, How to Speed up your web applications, Creating your own effects using Ajax.

All the tutorials under one roof.

Building a Spy
Step by step instructions on how to build a Digg like spy page.

Building a Shelf in WordPress
Nice tutorial on how to build a sliding shelf in Wordpress.

AJAX from Scratch: Implementing Mutual Exclusion in JavaScript
This AJAX from Scratch series of articles describes fundamental techniques needed to develop AJAX Rich Internet Applications in JavaScript from scratch.

Saving Session Across Page Loads Without Cookies, On The Client Side
This is a mini-tutorial on saving state across page loads on the client side, without using cookies so as to save large amounts of data beyond cookies size limits.

A Tale of Two IFrames or, How To Control Your Browsers History
This is a mini-tutorial on the black art of iframes and browser history, known to AJAX experts but rarely presented clearly.

AjaxWorld Special: What Is AJAX?
Learn more about AJAX and ColdFusion

Simple Ajax Functions - Snippets
I've created a list of very common JavaScript functions for Ajax. They have been created in quick reference fashion and do not contain any fancy stuff. Instead of creating one function which can handle various tasks depending on passed values, they are split into seperate basic task functions. The reason for this is simplicity.

AJAX Using ASP.NET 1.1
You've heard of it. It is the latest buzz term for web programmers these days. AJAX is an acronym that stands for Asynchronous JavaScript and XML. AJAX gains its popularity by allowing data on a page to be dynamically updated without having to make the browser reload the page. I will describe more about how AJAX works, and then go into some sample code to try out.

Speed up Your AJAX Based Webapps
It sets the expiry of the JavaScript to years and not days. Once the JavaScript file is downloaded it is never downloaded again, ofcourse unless you force it by removing the file in the cache. If you visit the site often the JavaScript will not be removed from the cache.

Kick-start your Java apps, Part 2
This tutorial guides you through the development of a small human-resources application, first using conventional JavaServer Pages (JSP) based technology, and then migrating it to a highly interactive solution using Ajax.

Howto integrate Google Calendar in your website using AJAX
One of the features I find it interesting in Google calendar is the possibility to create shared calendars, but also the availability of your calendar as XML or ICAL whatever it's a private or public one. As soon as we have XML of our calendar available I was wondering why not integrating Google calendar directly in website.

Create Your Own Ajax Effects
Why let script.aculo.us have all the fun? Start building your own Ajax-driven visual effects today. The basic and prebuilt effects in script.aculo.us are nice, but if you really want to build something great why not investigate doing your own, homegrown, do-it-yourself effects. We're going to show you how to take basic effects and build on them to create your own.

Hope you find these collection useful. If you find them useful, please drop in comments.

How to Implement Forms & Autocomplete using Ajax!!!!!

How to Implement Forms & Autocomplete using Ajax!!!!!

Scriptaculous Lists with PHP
The drag-and-drop effects, most notably the sortables, caught my eye because the look great, they are so easy to implement, and they're just so much nicer than the standard listbox with up/down arrows that we see in most of today's applications and administration tools.

Alter data with Ajax forms
Displaying rich formatted questions and lists, even paginated, is not enough to make an application live. And the heart of the askeet concept is to allow any registered user to ask a new question, and any user to answer an existing one. Isn't it time we get to it?

Dynamic Client LookupThis script uses AJAX to autofill a form. Open the demo and type in 1001 in the "client ID" text field. AJAX will when you have done this call a script on the server and auto fill the rest of the form with client data.

Chained Select BoxesThis script uses Ajax to popuplate a select box with cities based on which country you choose.

Ajax Dynamic ListThis script shows you a list of options based on what you type into a text input. Example: Type in "A" and Ajax will get you a list of all contries starting with "A".

Know of more scripts? Drop us a line/comment

How to Load Data Dynamically using Ajax?

These set of tutorials are collection of articles which teaches you how to load data dynamically using Ajax.

Ajax has become a new mantra of web. Its a must for sites now and for every developer as well.

Check these tutorials and let us know what you think

1. Dynamically loaded articles
This is a basic example showing you how to use AJAX. In this script, you have a list of article titles at the right side. When you click on one of them, AJAX will be used to request the content of the article from an external file and show it in the main DIV.

2. Ajax - Dynamic Content
This small generic script makes it easy for you to load content of external files into HTML elements on your page.

Know of more scripts? Let us know by dropping comments

Drag and Drop with Symfony Project. Coool Video Tutorial!!!!

Adding items to a shopping cart in common e-commerce applications isn't very close to the actual "add to cart" metaphor, since it requires clicking an "add to cart" button, watch a new page (the shopping cart), and then go back to the shop or checkout with buttons.

Ajax allows to get closer to the cart metaphor, by enabling drag-and-drop interactions and giving immediate visual feedback, without leaving the shop.

Check this cool video and learn how to make your own Drag-n-Drop script using PHP Framework, Symfony Project.
Drag and Drop Tutorial (with a cool video)

Make Ajax Based Chat Applications in Minutes!!!!!

Its the most comprehensive collection of all the Ajax based Chat systems.

Now, its very simple to just use these freely distributed code and demo so that one can integrate in any of the server side or client side for Chatting purpose.

One can also use them in their blogs and target readers and encourage user engagement.

AJAX Chat Sources Code for Download
After a slow start (following the announcement of the XHTML (ajax) Chat) things got finally busy. I had so many requests that I have decided to offer the complete sources for download.

Lace - Ajax ChatLace is a free, lightweight Ajaxian communications engine suitable for a shoutbox, chat room or similar. Version 0.1.3 brings with it several bug fixes, a tiny bit of code reorganization and most importantly, an oft-requested User List.

Most Simple Ajax Chat Ever
Very easy to use AJAX chat demo.

Know of more scripts? Drop in comments and share with us.

How to Create Ajax based Bookmarking system!!!!

A bookmarklet is a special piece of JavaScript code that can be dragged into a user's link toolbar, and which later can be clicked on to implement cross-site behavior. People have done all sorts of cool stuff with it.

I particularly found it very simple and agile.

JUst check this out and fall in love with it.
Creating Huge Bookmarklets

Know of more scripts? Drop in comments I shall add them here too.

How to Upload Files using Ajax and Progress Bar!!!!

Check this tutorial for more on how to upload files along with a Progress bar.

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

HowTo add Ajax in-progress indicators
Ok, so my little del.icio.us app (click link to read about how I added Ajax functionality to a simple Rails app) is pretty cool, but it was missing one big thing. When the user clicks the "Get Results" link she has no idea that the page is communicating with the server.

IF you know of any more Uploading file scripts, please drop in a comment.

How To Open PDFs in a New Window with JavaScript

Introduction

Opening documents such as PDFs in a new window should be automated using JavaScript for the following reasons:
1. Users will often close the web browser when a PDF is opened, mistakenly believing the document has been opened in Adobe Reader
2. The attribute historically used to open a new window, target, has been removed from the HTML 4.01 Strict specification (it's now deprecated)
3. Opening a new window is a behaviour and should be moved to the behavioural layer1.

Using JavaScript can also be particularly useful when a website is content managed. Rather than having to rely on site editors to remember to open a link to a PDF in a new window the process is handled by a simple JavaScript function.

Continue Reading

How to Create a Postgres and MySql Driver!!!!

The software that I write is not intended for just one customer who is locked into a single RDBMS. Instead it can be used by virtually any customer using the RDBMS of their choice. How is this possible? I deliberately designed and built my infrastructure around the 3 Tier Architecture which breaks down application code into three distinct areas of responsibility:

1. Presentation logic = User Interface, displaying data to the user, accepting input from the user.
2. Business logic = Business Rules, handles data validation and task-specific behaviour.
3. Data Access logic = Database Communication, constructing SQL queries and executing them via the relevant API.

It is only the Data Access layer which communicates with the database, therefore it should be possible to communicate with another database simply by changing the component which exists within this layer. I have already produced two versions of my Data Access Object for MySQL:
One for versions up to 4.0 which uses the original mysql_* functions.

Another for version 4.1 and above which uses the 'improved' mysqli_* functions.
The purpose of this article is to document my experiences while producing a DAO for a totally different RDBMS, in this case for PostgreSQL (version 8.0.3).

[source]

Understand, Why Stored Procedures are Evil!!!!!

A lot of developers are taught to use database stored procedures, triggers and database constraints at every possible opportunity, and they cannot understand why an old dinosaur like me should choose to take an opposite view.

The reason can be summed up quite simply:

You only know what you have been taught, whereas I know what I have learned.

I was weaned on file systems and databases which did not have any facilities for stored procedures and triggers, so I learned how to build applications without them. When such facilities became available my colleagues and I still never used them for practical reasons:

Continue Reading the tutorial

How to Install PHP on Windows!!!!

A brochure-style Web site may be sufficient for a business that simply wants a basic Web presence — some static pages to inform the visitor of the company's off-line contact information. But most organizations want a Web site that can interact with the visitor, delivering custom content in dynamically-generated pages, and storing visitor information in a database. Such a Web site requires several technologies: a Web server, a database system, and a scripting language for creating the Web pages. Currently the most popular choices are Apache, MySQL, and PHP, respectively.

Your PC can be turned into a fully capable Web development environment, by installing those three technologies, and configuring them so they communicate with one another. Admittedly, you can simply install and use PHP for its command-line processing. But for creating and testing dynamically generated Web pages on your local machine, then Apache needs to be already installed and working.

Continue Reading The Tutorial

Classes and Functions in PHP: Simple Tutorial for everyone

Classes and Functions in PHP: Simple Tutorial for everyone

A class is a function of PHP that has its roots in object oriented programming. The ability to use classes in PHP has been increasing with later versions. If you want to add the power of classes to your PHP programming, keep reading.
Introduction

Continuing our PHP functions article, we move on to creating classes. Let me say right at the start that you can write perfectly effective and useful PHP code without creating classes or going into object oriented programming. Another thing is that PHP, at its core, is not an object oriented language. This is because PHP was built from the C language, which is at its core a procedural language, rather than a methodical one. However, object oriented programming can be very powerful and PHP programmers are increasingly taking advantage of these capabilities, which have been greatly expanded since PHP4.

What is a class?

A class is a collection of variables and functions that serves a common purpose. It gives you the ability to think about real world objects and translate them into code. For example, let's try to describe a car. The class "car" might have variables: $name_of_car, $wheels, $steeringwheel, $windscreen, $lights, $pedals and $brakes. The functions of a car might include Turnleft(),Turnright() and Accelerate(). The function "Accelerate()" might take arguments such as $increase_speed. Now, all of the above describes a car and what a car does in both real terms and in code.

Now you might ask, couldn't this be done with regular functions and variables? Yes, it could, especially if you were talking about one car. But if you are talking about more than one car, then it would be impossible to keep up with all the various variables and functions associated with multiple cars. This is where classes become very useful, because classes bring all those variables and functions under one name. In this case, it's an object named "car." Now if you have more than one car, all you have to do is instantiate that object. The term instantiate basically means making a copy of the object. The new copy will have all the variables and functions of the original object available to it. You can include the class in any script that you create; the class will work the same.

Let me sound a cautionary note. Although OOP makes coding easier and more portable, the objects' execution time is less efficient than writing straight code. And while OOP speeds up project development drastically, more often than not, it produces less customized and slower applications. So, be aware of these pitfalls when choosing to use OOP.

OOP is arguably difficult to learn, so in this article I am going to use very simple examples to demonstrate how to use OOP. This should help new users grasp the concepts easily. Also, because OOP is such a huge topic I will only deal with the basics so as to give you the ability to easily learn the more advanced aspects of it.

For more read on here
http://www.devshed.com/c/a/PHP/Classes-as-PHP-Functions/

Cheerz
Web Coder

How-To: Upload a File in PHP?

How-To: Upload a File in PHP?

Introduction

Lately I have seen a ton of questions on the message board about uploading files to the server. It seems as if this is an epidemic that needs to be cured. I have written a PHP class for file uploads which some members of the message board have used and it helped to simplify their lives. Today we will attempt to write our own highly customizable file upload class. Before we get started get yourself a soda and something to munch on because this might take a while. Ready....(pause for the gathering of goodies)..okay let's begin.

What is a class and why do I need one?

Well to put it simply a class is a series of functions that work hand and hand to create an outcome. The reason a class works so great with uploading files is because there are a ton of functions one could write that would all depend on each other's outcome before the final result can be determined. For this reason we write a class instead of 10 functions and taking the time to validate each one.

Another beauty of a class is you can call any of the features within the class that you wish. For instance, with this class there will be 'x' amount of functions, all playing their role in the outcome of the actual upload process. If you wish to use this class to only verify a file's size and not upload it to the server, well you can. If you just wanted to get the file's extension and validate it, you could. That is the beauty of a class. If set up properly, classes are artwork, not just heavy amounts of code.

For rest of the tutorial read here.
http://www.phpfreaks.com/tutorials/85/0.php

--Srinix