xml ajax的区别,Ajax传参(普通文本和XML的区别).doc

Ajax传参(普通文本和XML的区别)

Ajax传参(普通文本和XML的区别)以及注意的地方时间: 2012-12-21 发送名/值对在您编写的 90% Web 应用程序中,最终都会使用名/值对发送到服务器。比方说,如果用户在网页表单中输入姓名和地址,可能希望数据采用下列形式:firstName=LarrylastName=Gullahornstreet=9018 Heatherhorn Drivecity=Rowlettstate=TexaszipCode=75080清单 1. 使用普通文本发送名/值对

function callServer() { // Get the city and state from the Web form var firstName = document.getElementById("firstName").value; var lastName = document.getElementById("lastName").value; var street = document.getElementById("street").value; var city = document.getElementById("city").value; var state = document.getElementById("state").value; var zipCode = document.getElementById("zipCode").value;

// Build the URL to connect to var url = "/scripts/saveAddress.php?firstName=" + escape(firstName) + "&lastName=" + escape(lastName) + "&street=" + escape(street) + "&city=" + escape(city) + "&state=" + escape(state) + "&zipCode=" + escape(zipCode);

// Open a connection to the server xmlHttp.open("GET", url, true);

// Set up a function for the server to run when it's done xmlHttp.onreadystatechange = confirmUpdate;

// Send the request xmlHttp.send(null);}将名/值对转化成 XML如果希望这样使用 XML 作为数据格式,首先要做的是找到一种基本 XML 格式来存储数据。显然,名/值对可以全部转化成 XML 元素,以其中的名称作为元素名,值作为元素的内容:LarryGullahorn9018 Heatherhorn DriveRowlettTexas75080清单 2. 用 XML 发送名/值对

function callServer() { // Get the city and state from the Web form var firstName = document.getElementById("firstName").value; var lastName = document.getElementById("lastName").value; var street = document.getElementById("street").value; var city = document.getElementById("city").value; var state = document.getElementById("state").value; var zipCode = document.getElementById("zipCode").value;

var xmlString = "" + " " + escape(firstName) + "" + " "

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值