Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript xmlHttp.responseText为空_Javascript_.net_Ajax_Xmlhttprequest - Fatal编程技术网

Javascript xmlHttp.responseText为空

Javascript xmlHttp.responseText为空,javascript,.net,ajax,xmlhttprequest,Javascript,.net,Ajax,Xmlhttprequest,xmlHttp.responseText为空,问题和解决方案是什么 default.aspx: 我用这个项目的复制粘贴创建了另一个项目;一切都是一样的,但第二个成功了。我很惊讶 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="xmlHttpOrnek._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML

xmlHttp.responseText为空,问题和解决方案是什么

default.aspx:


我用这个项目的复制粘贴创建了另一个项目;一切都是一样的,但第二个成功了。我很惊讶

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="xmlHttpOrnek._Default" %>

<!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">
<script type="text/javascript">
var xmlHttp;
function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
//--------------------------
function callAjaxFunc(val) {
        xmlHttp = GetXmlHttpObject();
        if (xmlHttp == null) {
            alert("Browser does not support HTTP Request");
            return;
        }

        //you can provide your page URL
        var url = "Default.aspx";
        url = url + "?kod=" + val;

        //state change event-this will occur ass soon as response comes from the url
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
}

function stateChanged() {

    if (xmlHttp.readyState == 4) 
    { //Display contents 
        var xmlResponse = xmlHttp.responseText;

        if (xmlResponse != '') {
            var inputMessage = document.getElementById('txb');
            inputMessage.value = xmlResponse.toString(); 
            alert(xmlResponse);
        }                    
    }
}
</script>
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:textbox ID="txb" runat="server"></asp:textbox>
        <asp:Button ID="btn" runat="server" Text="bas" OnClientClick="callAjaxFunc('y')" />
    </form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace xmlHttpOrnek
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string d = Request.QueryString["kod"];

            if (Request.QueryString["kod"] == "y")
            {
                Response.Write("Başarılı!");
                Response.End();
            }            
        }
    }
}