Ajax: A Web Development technology (asynchronous Javascript + XML)

Source: Internet
Author: User

  1. Create a new XMLHttpRequest object (the core of an Ajax application):
    <script language= "javascript" type= "Text/javascript" >    var xmlHttp = new XMLHttpRequest ();</script>
  2. Capturing and setting field values with JavaScript code
    Gets the form field with the ID value first_name var name = document.getElementById (' first_name '). value;//Modify the value of the form field with the ID value test document.getelemen Tbyid (' Test '). Value = Response[0];

      

  3. Create a XMLHttpRequest object on a Microsoft browser
    var xmlHttp = false;try {  xmlHttp = new ActiveXObject ("Msxml2.xmlhttp");} catch (e) {  try {    xmlHttp = new Acti Vexobject ("Microsoft.XMLHTTP");  } catch (E2) {    xmlHttp = false;  }}

      

  4. create XMLHttpRequest objects in a way that supports multiple browsers
    /* Create a new XMLHttpRequest object to talk to T He Web server */var xmlHttp = false;/* @cc_on @*//* @if (@_jscript_version >= 5) try {xmlHttp = new ActiveXObject ("Msxml 2.XMLHTTP ");}  catch (e) {try {xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");  } catch (e2) {xmlHttp = false; }} @end @*/if (!xmlhttp && typeof XMLHttpRequest! = ' undefined ') {xmlHttp = new XMLHttpRequest ();} 

  5. Getting started: Sending Ajax requests
    function CallServer () {  //Get the city and state from the Web Form  var city   = document.getElementById ("City") . value;  var state = document.getElementById ("state"). Value;  Build the URL to connect to  var url = '/scripts/getzipcode.php?city= ' + Escape (city) + ' &state= ' + Escape (state );  Open a connection to the server  xmlhttp.open ("GET", url, true);  Setup a function for the server to run when it's done  xmlhttp.onreadystatechange = updatepage;  Send the request  xmlhttp.send (null);}

      

Ajax: A Web Development technology (asynchronous Javascript + XML)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.