Tag: XML | Preview mode: Common | Row form

Using XML HTTP to load text file into HTML element

This AJAX example shows how  you can use an XMLHttpRequest to retrieve new content in an HTML element.

<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = "OK"
    document.getElementById('T1').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttp.statusText);
    }
  }
}
</script>
</head>

<body onload="loadXMLDoc('test_xmlhttp.txt')">
<div id="T1" style="border:1px solid black;height:40;width:300;padding:5"></div><br />
<button onclick="loadXMLDoc('test_xmlhttp2.txt')">Click</button>
</body>

Click here to read this article...

Tags: XML Ajax XMLHttpRequest

Categorize: AJAX | Link | Comment:1 | Read times: 49

Some basic knowledge of AJAX

AJAX = Asynchronous JavaScript and XML

AJAX is not a new programming language, but a technique for creating better, faster, and more interactive web applications.

With AJAX, your JavaScript can communicate directly with the server, using the JavaScript XMLHttpRequest object. With this object, your JavaScript can trade data with a web server, without reloading the page.

AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.

Click here to read this article...

Tags: basic knowledge Ajax JavaScript XML

Categorize: AJAX | Link | Comment:0 | Read times: 25

Two methods of processing external XML in Flex

There are two methods of processing XML data in Flex, mx:Model and mx:HTTPService. Here is the example code as follows:

//First method, use mx:Model

<?xml version="1.0"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
    <mx:Model id="catalogService" source="catalog.xml" />
    <mx:ArrayCollection id="myXC" source="{catalogService.product}"/>
    <mx:Repeater id="r" dataProvider="{myXC}" startingIndex="1">
        <mx:RadioButton id="Radio" label="{r.currentItem.name}"/>
    </mx:Repeater>
</mx:Application>

Second method: use mx:HTTPService

Click here to read this article...

Tags: Flex XML

Categorize: Flex | Link | Comment:0 | Read times: 44