ajax XMLHttpRequest post get
/*在有中文参数时,接收方需要使用UTF-8方式对数据进行解码
*不支持post附件
*/
function getXmlHttpRequest() {
var xmlHttpRequest = null;
try {
xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e1) {
try {
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttpRequest = null;
}
}
if (xmlHttpRequest == null && typeof(XMLHttpRequest) != 'undefined') {
xmlHttpRequest = new XMLHttpRequest();
}
return xmlHttpRequest;
}
/*使用post方式发送数据
*url:submit路径
*arguments:参数,如name=jese&sex=womanz,中文数据时使用'name='+getEncodeURIComponent('李四')+'&sex='+getEncodeURIComponent('男')进行编码
*synchFlag:同步标记,false为同步方式,true为异步方式
*returnType:返回内容类型0=responseBody;1=responseStream;2=responseText;3=responseXML
*execute:为异步方式提交后的回调函数,此函数用于处理返回数据,格式为function (obj){},obj为返回内容
*/
function postData(url, arguments, synchFlag, returnType, execute) {
var xmlHttpRequest = getXmlHttpRequest();
if (xmlHttpRequest == null) return false;
xmlHttpRequest.open("POST", url, synchFlag);
xmlHttpRequest.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
xmlHttpRequest.setRequestHeader("Content-Length", arguments.length);
if (synchFlag) {
xmlHttpRequest.onreadystatechange = function() {
&nb
相关文档:
<script language="javascript" type="text/javascript">
function doubleSalary()
{
var employee = new Object();
employee.FirstName = "X";
employee.LastName = "PP";
employee.Salary = 1000;
......
用Ajax实现Tab效果的
先创建
ajax.php,在其中输入如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample 2_1</title>
<me ......
如上图所示为Accordion控件:
感觉不错的样式
<style type="text/css">
.headerBg{cursor:hand;text-align:center;width:180px;height:21px;background-image:url(images/ajaxmenubg1.gif);FONT-SIZE: 12px;line-height:21px;} ......
在C#中
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;
using System.Collections;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.Ba ......
<html>
<body>
<script type="text/javascript">
function ajaxFunction()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Inte ......