婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Ajax 給 XMLHttpReq.onreadystatechange傳遞參數

Ajax 給 XMLHttpReq.onreadystatechange傳遞參數

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

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

Ajax 給 XMLHttpReq.onreadystatechange傳遞參數

通過:
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='....';
}
}
}

一個小測試的例子:
復制代碼 代碼如下:

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:
復制代碼 代碼如下:

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協議中的GET、POST的區別
  • 通過XMLHttpRequest和jQuery實現ajax的幾種方式
  • node.js+Ajax實現獲取HTTP服務器返回數據
  • javascript學習筆記(七)Ajax和Http狀態碼
  • 解析ajax核心XMLHTTPRequest對象的創建與瀏覽器的兼容問題
  • AJAX(XMLHttpRequest.status)狀態碼
  • 動態表單驗證的操作方法和TP框架里面的ajax表單驗證

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

巨人網絡通訊聲明:本文標題《Ajax 給 XMLHttpReq.onreadystatechange傳遞參數》,本文關鍵詞  Ajax,給,XMLHttpReq.onreadystatechange,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Ajax 給 XMLHttpReq.onreadystatechange傳遞參數》相關的同類信息!
  • 本頁收集關于Ajax 給 XMLHttpReq.onreadystatechange傳遞參數的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 乌拉特前旗| 金山区| 兰溪市| 湟中县| 株洲市| 洱源县| 嘉禾县| 丰台区| 长治县| 天水市| 阳信县| 建宁县| 阳江市| 桓台县| 南京市| 桃园县| 双桥区| 河北省| 渑池县| 黔东| 冕宁县| 科尔| 萝北县| 同心县| 新化县| 韩城市| 维西| 乐陵市| 奉节县| 东兴市| 航空| 青河县| 册亨县| 石首市| 简阳市| 巨鹿县| 子长县| 左权县| 慈溪市| 南召县| 介休市|