婷婷综合国产,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傳遞參數的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 图片| 宁城县| 乌兰县| 阿克苏市| 恩施市| 建始县| 麻栗坡县| 金堂县| 黔东| 达拉特旗| 孝义市| 宕昌县| 手游| 安乡县| 绥滨县| 南陵县| 广平县| 木里| 沙河市| 扶余县| 遂昌县| 通州市| 济南市| 襄垣县| 红桥区| 扎赉特旗| 仁布县| 吴堡县| 洱源县| 孝感市| 泰和县| 务川| 镇平县| 吴旗县| 济源市| 运城市| 赤壁市| 黔西| 西乡县| 柘城县| 易门县|