濮阳杆衣贸易有限公司

主頁 > 知識庫 > Ajax 給 XMLHttpReq.onreadystatechange傳遞參數(shù)

Ajax 給 XMLHttpReq.onreadystatechange傳遞參數(shù)

熱門標簽:襄陽外呼系統(tǒng)接口 科智聯(lián)智能電銷機器人 徐州電銷卡外呼系統(tǒng)供應(yīng)商 上海浦東百度地圖標注中心注冊 青海醫(yī)療智能外呼系統(tǒng)怎么樣 目標三維地圖標注 老虎郵局地圖標注點 外呼系統(tǒng)獲取客戶手機號 百靈鳥
Ajax 給 XMLHttpReq.onreadystatechange傳遞參數(shù)

通過:
xmlhttp.onreadystatechange= function(){xx(123)};
or xmlhttp.onreadystatechange= new Function("xx(123)"); 就可以了。
復(fù)制代碼 代碼如下:

Ajax 給 XMLHttpReq.onreadystatechange傳遞參數(shù)

通過:
xmlhttp.onreadystatechange= function(){xx(123)};
or
xmlhttp.onreadystatechange= new Function("xx(123)");
就可以了。
m=document.getElementsByName("text8");
v=m[i];
XMLHttpReq.onreadystatechange=function(){proce(v)};
----------------------------------------------
function proce(v)
{
if(XMLHttpReq.readyState==4)
{
if(XMLHttpReq.status==200)
{
var res=XMLHttpReq.responseXML.getElementsByTagName("content")[0].firstChild.data;
v.value=res;
}
else
{
v.value='....';
}
}
}

一個小測試的例子:
復(fù)制代碼 代碼如下:

html>
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312">
title>test Ajax/title>
mce:script language="javascript">!--
function getXMLHttpRequest() {
var xmlHttpRequest;
try
{
xmlHttpRequest=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
try
{
xmlHttpRequest=new ActiveXObjec("Msxml2.XMLHTTP");
}
catch (e)
{
throw new Error('Unable to create XMLHttpRequest.')
}
}
}
return xmlHttpRequest;
}
/*
function test() {
var xhr = getXMLHttpRequest();
var url="http://211.87.235.108:5000/sensor.xml";
xhr.open("GET",url);
xhr.send(null);
xhr.onreadystatechange = function(){
if(4==xhr.readyState)
{
if(200==xhr.status) {
//var xmldoc=xmlHttpRequest.responseXML;
var xmldoc=xhr.responseText;
document.getElementById("disp").innerHTML=xmldoc;
}
else {
//alert(xhr.status);
}
}
};

xhr.onstatechange = function() {
handleXMLHttpRequest(xhr) ;
};
}
*/

function handleXMLHttpRequest( xmlHttpRequest) {
if(4==xmlHttpRequest.readyState)
{
if(200==xmlHttpRequest.status){
//var xmldoc=xmlHttpRequest.responseXML;
var xmldoc=xmlHttpRequest.responseText;
document.getElementById("disp").innerHTML=xmldoc;
}
else {
alert(xmlHttpRequest.status);
}
}
}
function doXMLHttpRequest() {
var xhr = getXMLHttpRequest();
var url="http://localhost:5000/sensor.xml";
xhr.open("GET",url);
xhr.send(null);
xhr.onreadystatechange =function (){
handleXMLHttpRequest(xhr);
};
}

function myrefresh() {
window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
// -->/mce:script>

/head>
mce:style>!--
body {font-size:12px;}
-->/mce:style>style mce_bogus="1"> body {font-size:12px;}/style>
body onLoad="doXMLHttpRequest()">
div id="disp">
/div>
/body>
/html>

用例2:
復(fù)制代碼 代碼如下:

html>
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312">
title> My Documents /title>
mce:script language="javascript">!--
function getXMLHttpRequest() {
var xmlHttpRequest;
try
{
xmlHttpRequest=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
try
{
xmlHttpRequest=new ActiveXObjec("Msxml2.XMLHTTP");
}
catch (e)
{
throw new Error('Unable to create XMLHttpRequest.')
}
}
}
return xmlHttpRequest;
}
function test() {
var xhr = getXMLHttpRequest();
var url="http://211.87.235.108:5000/sensor.xml";
xhr.open("GET",url);
xhr.send(null);
xhr.onreadystatechange = function(){
if(4==xhr.readyState)
{
if(200==xhr.status) {
//var xmldoc=xmlHttpRequest.responseXML;
var xmldoc=xhr.responseText;
document.getElementById("disp").innerHTML=xmldoc;
}
else {
//alert(xhr.status);
}
}
};
}
/*
function handleXMLHttpRequest( xmlHttpRequest) {
alert(xmlhttpRequest + 2);
if(4==xmlHttpRequest.readyState)
{
if(200==xmlHttpRequest.status){
//var xmldoc=xmlHttpRequest.responseXML;
var xmldoc=xmlHttpRequest.responseText;
document.getElementById("disp").innerHTML=xmldoc;
}
else {
alert(xmlHttpRequest.status);
}
}
}

function doXMLHttpRequest() {
var xhr = getXMLHttpRequest();
var url="http://211.87.235.108:5000/sensor.xml";
xhr.open("GET",url);
xhr.send(null);
xhr.onreadystatechange = handleXMLHttpRequest();
}
*/

function myrefresh() {
window.location.reload();
}
// setTimeout('myrefresh()',1000); //指定1秒刷新一次
// -->/mce:script>

/HEAD>
mce:style>!--
body {font-size:12px;}
-->/mce:style>style mce_bogus="1"> body {font-size:12px;}/style>
body onLoad="test()">
div id="disp">
/div>
/body>
/html>
您可能感興趣的文章:
  • 如何解決Ajax訪問不斷變化的session的值不一致以及HTTP協(xié)議中的GET、POST的區(qū)別
  • 通過XMLHttpRequest和jQuery實現(xiàn)ajax的幾種方式
  • node.js+Ajax實現(xiàn)獲取HTTP服務(wù)器返回數(shù)據(jù)
  • javascript學習筆記(七)Ajax和Http狀態(tài)碼
  • 解析ajax核心XMLHTTPRequest對象的創(chuàng)建與瀏覽器的兼容問題
  • AJAX(XMLHttpRequest.status)狀態(tài)碼
  • 動態(tài)表單驗證的操作方法和TP框架里面的ajax表單驗證

標簽:佛山 股票 荊州 揭陽 咸寧 辛集 商洛 紅河

巨人網(wǎng)絡(luò)通訊聲明:本文標題《Ajax 給 XMLHttpReq.onreadystatechange傳遞參數(shù)》,本文關(guān)鍵詞  Ajax,給,XMLHttpReq.onreadystatechange,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Ajax 給 XMLHttpReq.onreadystatechange傳遞參數(shù)》相關(guān)的同類信息!
  • 本頁收集關(guān)于Ajax 給 XMLHttpReq.onreadystatechange傳遞參數(shù)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    沽源县| 尉氏县| 土默特右旗| 乐都县| 太保市| 吴桥县| 新河县| 阿拉尔市| 璧山县| 铜川市| 和平县| 葵青区| 随州市| 定西市| 额尔古纳市| 迭部县| 蒙城县| 精河县| 阳城县| 永城市| 工布江达县| 南靖县| 永德县| 乐东| 定兴县| 麻阳| 广宗县| 宾川县| 大冶市| 平泉县| 离岛区| 安多县| 宜黄县| 富蕴县| 奉贤区| 玛纳斯县| 株洲市| 石家庄市| 桂东县| 布拖县| 涪陵区|