HTTP请求 - 返回HTML格式 [英] HTTP Request - Returning HTML Format
本文介绍了HTTP请求 - 返回HTML格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试显示xmlhttp.responseText时返回HTML PAge。我想要显示字符串数据。
PLease帮助
我的代码:
(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
其他
{
xmlhttp = 新 ActiveXObject( Microsoft.XMLHTTP);
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200 ){
alert (xmlhttp.responseText); // 这显示结果为HTML PAGE
var response = eval(' (' + xmlhttp.responseText + ' )');
var status = 跨度>;
if (response.Data.length!= 0 ){
for ( var i = 0 ; i < response.Data.length; i ++){
for ( var value response.Data [ i]){
status = status + < option value = + response。 Data [i] [ value ] + > + response.Data [i] [ value ] + < /选项> 中跨度>;
}
}
}
其他 {
}
$( #ddItem)。html(status);
$( select#ddItem)。selectmenu( refresh);
}
else if (xmlhttp.status!= 200 ){
navigator.notification.alert( Coud not connect to the server,请检查您的互联网设置或联系系统管理员!, null ,' 连接失败',' OK');
}
}
var key = window.localStorage.getItem( userkey);
var clientid = window.localStorage.getItem( 的clientid跨度>);
var url = clientid + / GetInventory 跨度>;
xmlhttp.open( POST,url,真跨度>);
xmlhttp.timeout = 10000 ;
xmlhttp.ontimeout = function(){$ .mobile.loading( hide) ; navigator.notification.alert( Coud not connect to the server,请检查您的互联网设置或联系系统管理员! , null ,' 超时',' OK'); }
xmlhttp.send( key = + key);
解决方案
( #ddItem)。html(status);
( select#ddItem )。selectmenu( refresh);
}
else if (xmlhttp.status!= 200 ){
navigator.notification.alert( Coud not connect to the server,请检查您的互联网设置或联系系统管理员!, null ,' 连接失败',' OK');
}
}
var key = window.localStorage.getItem( userkey);
var clientid = window.localStorage.getItem( 的clientid跨度>);
var url = clientid + / GetInventory 跨度>;
xmlhttp.open( POST,url,真跨度>);
xmlhttp.timeout = 10000 ;
xmlhttp.ontimeout = function(){
.mobile.loading( 隐藏跨度>); navigator.notification.alert( Coud not connect to the server,请检查您的互联网设置或联系系统管理员! , null ,' 超时',' OK'); }
xmlhttp.send( key = + key);
Hi,
While trying to Display "xmlhttp.responseText" Its returning HTML PAge. I want string data to be displayed.
PLease help
My code :
(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText); //This is showing Result as HTML PAGE
var response = eval('(' + xmlhttp.responseText + ')');
var status = " ";
if (response.Data.length != 0) {
for (var i = 0; i < response.Data.length; i++) {
for (var value in response.Data[i]) {
status = status + "<option value=" + response.Data[i][value] + ">" + response.Data[i][value] + "</option>";
}
}
}
else {
}
$("#ddItem").html(status);
$("select#ddItem").selectmenu("refresh");
}
else if (xmlhttp.status != 200) {
navigator.notification.alert("Coudn't connect to the server,Please check your internet settings or contact system administrator!", null, 'Connection Failed', 'OK');
}
}
var key = window.localStorage.getItem("userkey");
var clientid = window.localStorage.getItem("clientid");
var url = clientid + "/GetInventory";
xmlhttp.open("POST", url, true);
xmlhttp.timeout = 10000;
xmlhttp.ontimeout = function () { $.mobile.loading("hide"); navigator.notification.alert("Coudn't connect to the server,Please check your internet settings or contact system administrator!", null, 'Timed Out', 'OK'); }
xmlhttp.send("key=" + key);
解决方案
("#ddItem").html(status);
("select#ddItem").selectmenu("refresh"); } else if (xmlhttp.status != 200) { navigator.notification.alert("Coudn't connect to the server,Please check your internet settings or contact system administrator!", null, 'Connection Failed', 'OK'); } } var key = window.localStorage.getItem("userkey"); var clientid = window.localStorage.getItem("clientid"); var url = clientid + "/GetInventory"; xmlhttp.open("POST", url, true); xmlhttp.timeout = 10000; xmlhttp.ontimeout = function () {
.mobile.loading("hide"); navigator.notification.alert("Coudn't connect to the server,Please check your internet settings or contact system administrator!", null, 'Timed Out', 'OK'); } xmlhttp.send("key=" + key);
这篇关于HTTP请求 - 返回HTML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文