AjaxGold(下载) 提供了4个函数供开发者调用:
getDataReturnText(url,callback);
getDataReturnXML(url,callback);
postDataReturnText(url,data,callback);
postDataReturnXML(url,data,callback);
下面以postDataReturnXML(url,data,callback)为例。简要说明:
9-8.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test</title>
<script language="javascript" src="ajaxgold.js"></script>
<script language="javascript">
function display(text){
document.getElementById("targetID").innerHTML = text;
}
</script>
</head>
<body>
<form>
<input type="button" value="get the message">
</form>
<div>The fetch data will go here</div>
</body>
</html>
9-8.aspx:
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.IO" %>
<%
Response.ContentType = "text/xml";
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma","no-cache");
int a = int.Parse(Request["a"]);
int b = int.Parse(Request["b"]);
Response.Write(a+b);
%>
结果为:5