Results 1 to 6 of 6

Thread: How to create the XMLHttpRequest Object?

  1. #1
    Join Date
    Aug 2006
    Posts
    222

    How to create the XMLHttpRequest Object?

    I have done some basic things with a XML (Extensible Markup Language). Now I want to communicate with the server from inside a web page. I came to know that using XMLHttpRequest Object will help me to communicate with the server. But, I don't know how to create the XMLHttpRequest Object? Also I am having doubt that using the XMLHttpRequest Object, does it update a web page with new data without reloading the page..?? Please help me to solve my problem.
    Just a reply to say thank you for these links and posts I have a lot to read and learn now!



  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: How to create the XMLHttpRequest Object?

    You can use the XMLHttpRequest Object for communicating with your server from inside a web page. Also after using a XMLHttpRequest Object, the web page with new data gets updated without reloading the page. I am sure that your doubt will be cleared about the updating the web page..!! Also by using this object, it requests and receive new data from a server after the page has loaded. You can also communicate with a server in the background by creating a XMLHttpRequest Object. Hope that you have got some useful information from this reply..!!

  3. #3
    Join Date
    Mar 2008
    Posts
    349

    Re: How to create the XMLHttpRequest Object?

    If you want to submit form data or load data from a server then you can use the XMLHttpRequest object. The XMLHttpRequest object implements an interface exposed by a scripting engine that allows scripts to perform HTTP client functionality. An XMLHttpRequest object supports any text based format, including XML. If you want to make requests over both HTTP, you can use this object. You can understand bit more after looking the following example :
    Code:
    function test(data)
    {
     
    }
    
    function handler() {
     if(this.readyState == 4 && this.status == 300) {
      if(this.responseXML != null && this.responseXML.getElementById('test').firstChild.data)
       test(this.responseXML.getElementById('test').firstChild.data);
      else
       test(null);
     } else if (this.readyState == 4 && this.status != 300) {
      test(null);
     }
    }
    
    var client = new XMLHttpRequest();
    client.onreadystatechange = handler;
    client.open("GET", "test.xml");
    client.send();

  4. #4
    Join Date
    Mar 2008
    Posts
    672

    Re: How to create the XMLHttpRequest Object?

    You can create an XMLHttpRequest object, just by writing a single line of JavaScript. If you are working on older browsers (like Internet Explorer 5 and 6), then use the following code :
    Code:
    var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    And if you are using modern browsers than you can use :
    Code:
    var xmlhttp=new XMLHttpRequest()

  5. #5
    Join Date
    Jul 2006
    Posts
    442

    Re: How to create the XMLHttpRequest Object?

    This is little bit tough to understand, but you will have to take a look to clear your concepts about the XMLHttpRequest Object. Each XMLHttpRequest object has an associated XMLHttpRequest origin and an XMLHttpRequest base URL. The specification defines their values when the global object is represented by the Window object. When the XMLHttpRequest object used in other contexts their values will have to be defined as appropriate for that context. Also the user agent must return a new XMLHttpRequest object when the XMLHttpRequest() constructor is invoked.
    "When they give you ruled paper, write the other way..." J.R.J.

  6. #6
    Join Date
    Nov 2008
    Posts
    996

    Re: How to create the XMLHttpRequest Object?

    The onreadystatechange is an event handler attribute which has to handle event type readystatechange by the XMLHttpRequest object.The XMLHttpRequest object can be in several states. The readyState attribute, on getting, must return the current state, which must be one of the following values :
    • UNSENT (numeric value 0) means that the object has been constructed.
    • OPENED (numeric value 1) refers that open() method has been successfully invoked.
    • HEADERS_RECEIVED (numeric value 2) comes when all HTTP headers have been received.
    • LOADING (numeric value 3) means that the entity body is being received.
    • DONE (numeric value 4) This value comes when the data transfer has been completed. It also comes when something is wrong in transfer of data.

Similar Threads

  1. How to create an Object in Arrays?
    By sRIPRIYA in forum Software Development
    Replies: 4
    Last Post: 14-12-2010, 12:59 AM
  2. Replies: 5
    Last Post: 05-01-2010, 05:42 PM
  3. How to create object in Autocad
    By InterMania in forum Windows Software
    Replies: 3
    Last Post: 30-10-2009, 11:26 PM
  4. How to create object in JAVA
    By HP_Crook in forum Software Development
    Replies: 3
    Last Post: 09-10-2009, 11:52 PM
  5. How many ways to create an object for class
    By Shanbaag in forum Software Development
    Replies: 3
    Last Post: 25-04-2009, 10:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,518,928.28299 seconds with 16 queries