Step 1

Enter your contact information.

Step 2

Enter your project information.

Step 3

Choose the PHP programmers you want to hire.

Compare Free PHP Quotes





Country



Simple AJAX Function with Example

*Attention PHP Programmers* - Add A Free Listing! Get more clients.

Win a new Compaq Presario Notebook!

Below is the simple AJAX function that I use in many of my projects, TinyAjax. It makes it easy to call and process GET and POST transactions. Here are the parameters:

  1. URL (required)
  2. ID of the output element (pass a zero/false for no response output)
  3. String of function to be evaluated and called on completion (optional)
  4. Post content – example: id=22&action=1 (optional)

I will be posting more small snippets soon as well as some updates to previous scripts, new code, and tutorials. Last year was roller coaster with getting my business off the ground and it shows in my lack of time for this site. That being said, I plan to take more time to give back  this year and grow my own skills so expect to see much more of me on here. I cleaned up the forums and implemented DISQUS to help everyone get the most out of this site.

On a side note, I have formed a new company this year with a partner and we are opening an office in historic downtown Franklin, TN. We will be looking for some good people to work with us so if you or anyone you know is in the Nashville area, please have them drop me a line.

TINY={};

function T$(id){return document.getElementById(id)}

TINY.ajax=function(){
    return{
        call:function(u,d,f,p){
            var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
            x.onreadystatechange=function(){
                if(x.readyState==4&&x.status==200){
                    if(d){
                        var t=T$(d);
                        t.innerHTML=x.responseText
                    }
                    if(f){
                        var c=new Function(f); c()
                    }
                }
            };
            if(p){
                x.open('POST',u,true);
                x.setRequestHeader('Content-type','application/x-www-form-urlencoded');
                x.send(p)
            }else{
                x.open('GET',u,true);
                x.send(null)
            }
        }
    };
}();

A call would look something like the following:

TINY.ajax.call('get.php?id=32', 'content', 'display("red")'); // GET
TINY.ajax.call('post.php', 'content', 'display("green")', 'id=32'); // POST

Click here for the demo.

Click here to download a fully working example in PHP.

Keep in mind that this will not work on your local computer unless you are running a web server like Apache. This script has been tested in all major browsers and is available free of charge for both personal or commercial projects under the creative commons license. Community support is available here.

Source http://www.scriptiny.com/?p=362
Tue, 18 Jan 2011 03:15:09 GMT
Tags: AJAX, JavaScript,

*Attention PHP Programmers* - Add A Free Listing! Get more clients.


AJAX


JavaScript


JavaScript Fade Tutorial – Fading Elements In/Out

One of the most common JavaScript effects is fading elements and text in and out. Fortunately, it isn't very difficult to script and doesn't require a JavaScript framework.

JavaScript Slider – TinySlider 2

This full-featured and standalone JavaScript slider is easily configurable and visually customizable using CSS. It also clocks in at a tiny 3KB.

Members:
Marina Del Rey
Perlman Creative Group Profile
Perlman Creative Group

Perlman Creative Group is a Los Angeles based, full service graphic design firm specializing in marketing communication, brand development, logos, packaging, corporate identity and website design.

Marina Del Rey, California US
Zrenjanin
Mirza Delic Profile
Mirza Delic

PHP/MySQL Developer

Zrenjanin, Vojvodina RS
Rocky River
Lytell Designs Profile
Lytell Designs

Creating unique design solutions that are both affordable and inspiring. Specializing in design, layout & production of printed materials, logos & illustrations.

Rocky River, Ohio US
Milwaukee
Thoreson Web Designs Profile
Thoreson Web Designs

Thoreson Web Designs is a Wisconsin-based web design business located in Milwaukee. I have experience with an array of tools and programs, and understand the importance of project management.

Milwaukee, Wisconsin US
Sacramento
Technicate Solutions, Inc Profile
Technicate Solutions, Inc

Technicate Solutions, Inc. is a fast-growing IT Consulting firm servicing the Sacramento area and beyond. We combine innovative technologies with business savvy to make successful projects happen.

Sacramento, California US
Design Leads


PHP Programmers Valid HTML 4.0 Transitional Valid CSS!

Firefox 4: 7 Million Downloads and Counting

With over 7 million downloads and counting, Firefox 4 looks on track to match, and possibly surpass,



Build Faster Mobile Websites With ‘Adaptive Images’

Responsive design means your website can adapt to any screen size, but without some extra help your



HTTPS Is More Secure, So Why Isn’t the Web Using It?

You wouldn’t write your username and passwords on a postcard and mail it for the world to see,



Automate and Sync Your Web With ‘If This, Then That’

The awkwardly named, but fantastically useful, Ifttt.com (short for “if this then that”)



Got Messy CSS? You’re not Alone

Woolly, the CSS sheep. You just got a new web design gig. There’s a blank CSS file staring ou



Article Tags
PHP Programmers Articles
Browsers| Web Standards| CSS| HTML5| Web Basics| firefox| Programming| Web Services| Mobile| JavaScript| Web Development| Multimedia| Visual Design| chrome| Google| responsive design| This Week in Web| CSS 3| Opera| Social|
Friends:
Live Help Chat Software
Web Design Quote
Web Design