AJAX Intro

AJAX Request Build

AJAX Examples


External Ajax File Example Demo


Ajax code you can implement into external js file same as JavaScript. and after linked with the web page.

Following example is external Ajax implemented code are linked with main web page. You can use that external file in multiple web page.

Example Code

ajax.js
function external_ajax(){
    var xhr = null;
    try {
        xhr = new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch (e) {
        try {
            xhr = new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch (e) {
    		try {
    			xhr = new XMLHttpRequest();
    		} catch (e) {
    			xhr = false;
    		}
        }
    }
    return xhr;
}

Example Code

external_ajax_demo.html
<html>
<head>
    <script src="ajax.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
	var xhr = external_ajax();
	document.write("Return Response for External File:  " + 
    "<br />" +
    "Your browser support " + xhr + " object");
</script>
</body>
</html>

Run it...   »


Example Result