Found Ajax is really good dongdong: You can only pass the XML simple client want data.
Client Ajax Code:
<script language= "JavaScript" type= "Text/javascript" >
<!--
Initiates a XMLHTTP request to the server.
var http_request = null;
function GetData ()
{
Start initializing the XMLHttpRequest object
if (window. XMLHttpRequest)//mozilla Browser
{
Http_request = new XMLHttpRequest ();
if (http_request.overridemimetype) {//Set MIME category
Http_request.overridemimetype (' Text/xml ');
}
}
else if (window. ActiveXObject)//IE browser
{
Try
{
Http_request = new ActiveXObject ("Msxml2.xmlhttp");
}
catch (E)
{
Try
{
Http_request = new ActiveXObject ("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
exception, creating object instance failed
if (!http_request)
{
Window.alert ("Cannot create XMLHttpRequest object instance.");
return false;
}
Http_request.onreadystatechange = ProcessResponse;
Determine how the request is sent
Http_request.open ("Get", ".. /cgi-bin/status.cgi ", true);
Http_request.send (NULL);
}
Functions that process return information
function ProcessResponse ()
{
if (http_request.readystate = = 4)//Judging object status
{
if (Http_request.status = 200)//information has been successfully returned to begin processing information
{
var result = Http_request.responsetext;
if (Result.indexof ("#")!=-1)
{
Show (result);
}
Else
{
}
}
else//page is not normal
{
Alert ("The page you are requesting has an exception.) ");
}
}
}
The CGI side can use the Cgic library (a good library, but main () in the library, the main () to a common interface is the best):
#include <stdio.h>
#include "cgic.h"
#include <string.h>
#include <stdlib.h>
int Showinfo ();
int Cgimain ()
{
Cgiheadercontenttype ("text/html"); Not less
* Now show the form * *
fprintf (Cgiout, "1#2#3#", szName);
return 0;
}