Ajax技术中的XMLHttpRequest对象传值问题
时间:2011-12-25
来源:互联网
现在有一个A.aspx页面,B.aspx页面是A.aspx的处理页面。我的问题是:通过XMLHttpRequest对象来传值,当我要的传的值很多时,该怎么办呢?
或者为了达到这种效果,还有没有别的方法呢?
问号传参的方式,可不可以传集合呢?
请高手解答,我很急。就要交项目了。
或者为了达到这种效果,还有没有别的方法呢?
问号传参的方式,可不可以传集合呢?
请高手解答,我很急。就要交项目了。
作者: trytoit 发布时间: 2011-12-25
用 POST 啊。google 一搜一大把啊。
http://www.diybl.com/course/4_webprogram/xml/xml_js/2007111/81586.html
红色部分,即把你要post的值组装起来的值。
function Request(url) {
var xmlHttp = CreateXMLHttpRequest();
var content = "m_title=title&m_content=content";
xmlHttp.open('POST', url, true);
xmlHttp.setRequestHeader("Content-Length", content.length);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
alert(xmlHttp.responseText);
}
}
}
xmlHttp.send(null);
}
http://www.diybl.com/course/4_webprogram/xml/xml_js/2007111/81586.html
红色部分,即把你要post的值组装起来的值。
function Request(url) {
var xmlHttp = CreateXMLHttpRequest();
var content = "m_title=title&m_content=content";
xmlHttp.open('POST', url, true);
xmlHttp.setRequestHeader("Content-Length", content.length);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
alert(xmlHttp.responseText);
}
}
}
xmlHttp.send(null);
}
作者: fangxinggood 发布时间: 2011-12-25
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function A(id)
{
if (id == "")
return;
var url = "../RegistValidate.ashx?username=" + escape(id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = ShowResult;
xmlHttp.send(null);
}
function ShowResult() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var s;
s = xmlHttp.responseText;
}
else {
}
}
}
获取多个值可使用JSON传递
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function A(id)
{
if (id == "")
return;
var url = "../RegistValidate.ashx?username=" + escape(id);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = ShowResult;
xmlHttp.send(null);
}
function ShowResult() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var s;
s = xmlHttp.responseText;
}
else {
}
}
}
获取多个值可使用JSON传递
作者: wuyq11 发布时间: 2011-12-25
引用 1 楼 fangxinggood 的回复:
用 POST 啊。google 一搜一大把啊。
http://www.diybl.com/course/4_webprogram/xml/xml_js/2007111/81586.html
红色部分,即把你要post的值组装起来的值。
function Request(url) {
var xmlHttp = CreateXMLHttpRequest();
var con……
用 POST 啊。google 一搜一大把啊。
http://www.diybl.com/course/4_webprogram/xml/xml_js/2007111/81586.html
红色部分,即把你要post的值组装起来的值。
function Request(url) {
var xmlHttp = CreateXMLHttpRequest();
var con……
可不可以把一个数组放入url中呢?然后处理页面接收这个数组。
作者: trytoit 发布时间: 2011-12-25
引用 2 楼 wuyq11 的回复:
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp =……
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp =……
如梦出山了?
作者: vip__888 发布时间: 2011-12-25
引用 3 楼 trytoit 的回复:
引用 1 楼 fangxinggood 的回复:
用 POST 啊。google 一搜一大把啊。
http://www.diybl.com/course/4_webprogram/xml/xml_js/2007111/81586.html
红色部分,即把你要post的值组装起来的值。
function Request(url) {
var xmlHttp = CreateXML……
引用 1 楼 fangxinggood 的回复:
用 POST 啊。google 一搜一大把啊。
http://www.diybl.com/course/4_webprogram/xml/xml_js/2007111/81586.html
红色部分,即把你要post的值组装起来的值。
function Request(url) {
var xmlHttp = CreateXML……
完全可以啊。POST只知道传 key=value&key1=value1 的字符串。
value 里的内容完全可以你自己拼装,比如 1,2,3,4 服务端自行分割就是了。
作者: fangxinggood 发布时间: 2011-12-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28