Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Javascript / VB Script JavaScript and VBScript are interpreted, scripting languages that let you embed simple programs into Web pages. JavaScript/VBScript programs are embedded directly within the HTML document. When the browser loads the HTML document, the programs are also loaded.

Javascript / VB Script Thread, JavaScript XMLHttpRequest Object Tutorial in Web Development; JavaScript XMLHttpRequest Object Tutorial Here is an example of XMLHttpRequest Object using: PHP Code:    function moveCalendar ( month , ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6885


Reply
LinkBack (1) Thread Tools Display Modes
JavaScript XMLHttpRequest Object Tutorial
 
 
The God Father
Developer's Avatar

Reply With Quote
Thanks: 1
Thanked 212 Times in 154 Posts
 
Join Date: Jul 2008
Location: NDC
Posts: 5,426
01-12-2008, 11:52 PM
 
JavaScript XMLHttpRequest Object Tutorial

Here is an example of XMLHttpRequest Object using:
PHP Code:

  
function moveCalendar(month, year)
{
    var
xmlHttp;
    
// Create xmlHttp Object
    
try
    
{
        
// Firefox, Opera 8.0+, Safari
        
xmlHttp = new XMLHttpRequest();
    }
    
catch (e)
    {
        
try
        
{
            
// Internet Explorer
            
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        
catch (e)
        {
            
try
            
{
                
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            
catch (e)
            {
                
alert("Your browser does not support AJAX!");
                return
false;
            }
        }
    }
    
// Event Handler - EventListener
    
xmlHttp.onreadystatechange = function()
    {
        if (
xmlHttp.readyState == 4) // 4: The Request is complete
        
{
            
document.getElementById('calendar').innerHTML = xmlHttp.responseText; // Response
        
}
    }
    
// Request
    
xmlHttp.open("GET", "/modules/mod_calendar.php?month="+month+"&year="+year, true);
    
xmlHttp.send(null);
}
</div> Stated above example tries to create an XMLHttpRequest Object. If successfull, a function is triggered by XMLHttp state change which reacts to the request represented by last two lines of the code. PHP script (calendar module in this case) expects a GET requests and returns the HTML code of the calendar portion (a month) specified by request (month and year). This returned code is then pushed into the page code by setting the HTML DOM property innerHTML to the value of XMLHttp response.
But what is this complicated manner good for? The main advantage is that by using XMLHttpRequest Object you don’t have to reload whole page when trying to retrieve some information. There’s just small part of page changed which result in very fast, dynamic effect of updating the data. Also, pushing a data to database is carried out much effective in case of XMLHttpRequest Object use.
Coding a script using XMLHttpRequest Object can be done manually (every action is coded separately) or you can use one of the frameworks which incorporates AJAX or offers nice interface to your existing PHP code. I personally, prefer the second type, so I use the xAJAX library where an XMLHttpRequest Object should be convenient. The goal of the xAJAX object is that you don’t have to change anything in your existing application source code. Just load the library, create object, register the function or class you want to handle by AJAX and that’s it!
Finally, there should be noted that from security reasons the XMLHttpRequest Object works within a domain only! It means that call of some location outside the domain leads to security error like this:
Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "http://www.testfiles.loc/js/testfile.js Line: 43"]
I hope, this brief intro into the XMLHttpRequest Object gave you at least basic overview of AJAX technology.
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
 
Junior Member

Reply With Quote
Thanks: 0
Thanked 0 Times in 0 Posts
 
Join Date: Jan 2009
Posts: 3
13-01-2009, 02:00 PM
 
Hi,
Dude i don't understand What are you really want to say.
So please clear with your thoughts.So, We understand you easily
And may provide some better help to you.
You can also find me at my signature.
I will gonna happy to help you.
Thanks
___________________
bannerblindness
 
 
 
Reply

Javascript / VB Script Thread, JavaScript XMLHttpRequest Object Tutorial in Web Development; JavaScript XMLHttpRequest Object Tutorial Here is an example of XMLHttpRequest Object using: PHP Code:    function moveCalendar ( month , ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6885


Bookmarks

Tags
javascript, object, tutorial, xmlhttprequest


LinkBacks (?)
LinkBack to this Thread: http://forum.egypt.com/enforum/javascript-vb-script-f128/javascript-xmlhttprequest-object-tutorial-6885.html
Posted By For Type Date
Everything about xmlhttprequest - Yahoo! Glue This thread Refback 02-12-2008 01:11 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Displaying self updating time on a webpage Tutorial Developer Javascript / VB Script 1 23-05-2009 06:45 AM
Getting Browser details and Version Detection using JavaScript Developer Javascript / VB Script 1 13-01-2009 01:53 PM
The Sims 2 - Object pack ! Developer Software and Programs 0 27-12-2008 03:08 PM
Adding Javascript to your Template Developer Articles 0 27-10-2008 08:44 PM
Hide certain things from users that have javascript disabled Developer Articles 0 10-09-2008 05:44 PM