当前位置: 代码迷 >> Ajax >> ASP.NET ajax responseText回来的却是网页的HTML代码,求解
  详细解决方案

ASP.NET ajax responseText回来的却是网页的HTML代码,求解

热度:225   发布时间:2013-01-02 13:08:44.0
ASP.NET ajax responseText返回的却是网页的HTML代码,求解
如题,
我用一个aspx 页面写js请求一个一般处理程序
然而,给我返回的却是是aspx整个页面的代码,
我在一般处理程序里面设置断点, 竟然没有跳过去
这是不是能说明,他请求没成功。
但是,ajax返回来的那两个状态却是成功的
readystate==4
staus==200
这是为何呢,
求高手解答!!
一下是代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test11.aspx.cs" Inherits="Test11" %>

<%--<%@ Register src="control/TestCity.ascx" tagname="TestCity" tagprefix="uc1" %>--%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
<%--  <script src="js/ajax.js" type="text/javascript"></script>--%>
    <script type="text/javascript">

        var xmlHttp = null;
        function loadXmlHttp() {
            if (window.XMLHttpRequest) { // IE7, Mozilla, Safari, Opera, etc.
                xmlHttp = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // IE 5.x and 6
                }
                catch (e) {

                    alert(e);
                }
            }
        }

        function sendRequest() {
            // alert(url);
            loadXmlHttp();
          //  alert(xmlHttp);
            if (xmlHttp) {

                // Open HTTP connection to url.
                xmlHttp.open("GET", "ChangeCity.ashx", true); // true = async

                // Define the callback function for async call
                xmlHttp.onreadystatechange = onCallback;

                // Specify form data in request body
                xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  相关解决方案