[size=16px]
前台代码如下:[/size]
<script type="text/javascript">
$(function () {
$("#send").click(function () {
$.ajax({
type: "GET",
url: "test1.xml",
dataType: "xml",
success: function (data, textStatus) {
alert(data);
$("#resText").html(data+textStatus); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown); }
});
$("#loading").ajaxStart(function () {
$(this).show();
});
$("#loading").ajaxStop(function () {
$(this).hide();
});
}) })
</script>xml文件如下:
<?xml version="1.0" encoding="utf-8"?>
<!--注释内容-->
<table border="1">
<tbody>
<tr>
<td>fdjkfdfkdkkdf</td>
</tr>
</tbody>
</tabl
问题:我想返回xml中的数据,结果返回的是【objectDocument】这句话,不知道哪里出问题了,请高手指教。
前台代码如下:[/size]
<script type="text/javascript">
$(function () {
$("#send").click(function () {
$.ajax({
type: "GET",
url: "test1.xml",
dataType: "xml",
success: function (data, textStatus) {
alert(data);
$("#resText").html(data+textStatus); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown); }
});
$("#loading").ajaxStart(function () {
$(this).show();
});
$("#loading").ajaxStop(function () {
$(this).hide();
});
}) })
</script>xml文件如下:
<?xml version="1.0" encoding="utf-8"?>
<!--注释内容-->
<table border="1">
<tbody>
<tr>
<td>fdjkfdfkdkkdf</td>
</tr>
</tbody>
</tabl
问题:我想返回xml中的数据,结果返回的是【objectDocument】这句话,不知道哪里出问题了,请高手指教。
dataType: "xml", // 你接受的是一个xml 对象,不是字符串,所以不能这样直接 alert
success: function (data, textStatus) {
alert(data); // data 是一个对象 ! 你应当 取它的属性值!
$("#resText").html(data+textStatus); },
$("#send").click(function () {
$.ajax({
type: "GET",
url: "XMLFile.xml",
dataType: "xml",
success: function (data, textStatus) { $("#resText").html($(data).find('table').text()); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown); }
});
$("#loading").ajaxStart(function () {
$(this).show();
});
$("#loading").ajaxStop(function () {
$(this).hide();
});
}) })
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>未命名頁面</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="send" type="button" value="Send"/>
<div id="loading" style="height:50px;width:400px;background-color:honeydew;display:none;" ></div>
<div id="resText" style="height: 50px; width: 400px;
background-color: #FFDDFF">
</div>
</div>
</form>
</body>
</html>
<script type="text/javascript"> $(function () {
$("#send").click(function () {
$.ajax({
type: "GET",
url: "XMLFile.xml",
dataType: "xml",
success: function (data, textStatus) { $("#resText").html($(data).find('table').text()); },
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown); }
});
$("#loading").ajaxStart(function () {
$(this).show();
});
$("#loading").ajaxStop(function () {
$(this).hide();
});
}) })
</script>