未定义-ajax方法错误

未定义-ajax方法错误,ajax,undefined,Ajax,Undefined,大多数问题我都是这样想的,我尝试了很多方法来解决这个问题,但是我做不到 var kullaniciAdi = '<%= Session["kullanici"] %>'; alert(kullaniciAdi); $.ajax({ url: "http://localhost:63000/GetInfoService.asmx/GetInfos", type: "POST", dataType:'json',

大多数问题我都是这样想的,我尝试了很多方法来解决这个问题,但是我做不到

var kullaniciAdi = '<%= Session["kullanici"] %>';
    alert(kullaniciAdi);
    $.ajax({
        url: "http://localhost:63000/GetInfoService.asmx/GetInfos",
        type: "POST",
        dataType:'json',
        data: JSON.stringify({ kullaniciAdi: kullaniciAdi }),
        contentType: "application/json; charset=windows-1254",
        success: function (infos) {
            var items = infos.d;
            $jQuery.each(items, function (index, val) {
                $("div#adSoyad").html('<h1>' + val[index].ad + " " + val[index].soyad + '</h1>');
                $("div#fotograf").html('<img src="' + val[index].fotograf + '" class="img-responsive">');
            });
        },
        error: function (e) {
            alert(e.leader);
        }
    });

对不起我的英语:)

“不管我做了什么,它都不起作用。”。它怎么不起作用?你犯了什么错误?对不起,先生。这是未定义的错误错误错误的全文是什么?哪一行导致该错误?警告框显示未定义。我认为“var kullaniciAdi=””之后的ajax方法是不正确的部分。错误显示错误:函数(e){alert(e.leader);}当然。否则将成功:)而不是
alert()
使用
console.log()
并打开浏览器的调试控制台以查看输出。您将获得更好的调试帮助,并可以检查变量内容。
 public class GetInfoService : System.Web.Services.WebService
{
    [WebMethod]
    public List<kullaniciBilgileri> GetInfos(string kullaniciAd)
    {
        List<kullaniciBilgileri> infos = new List<kullaniciBilgileri>();
        try
        {
            SqlConnection conn = new SqlConnection("Data Source=.\\SQLExpress; Initial Catalog=twitter;Integrated Security=SSPI");
            if (conn.State == ConnectionState.Closed)
                conn.Open();

            SqlCommand cmd = new SqlCommand("SELECT ad,soyad,fotograf FROM tblKullanici WHERE kullaniciAdi = @kullaniciAd");
            cmd.CommandType = CommandType.Text;
            cmd.Connection = conn;
            cmd.Parameters.AddWithValue("@kullaniciAd", kullaniciAd);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                var kullanici = new kullaniciBilgileri
                {
                    ad = dr["ad"].ToString(),
                    soyad = dr["soyad"].ToString(),
                    fotograf = dr["fotograf"].ToString()
                };
                infos.Add(kullanici);
            }
            return infos;
        }
        catch (SoapException se)
        {
            throw se;
        }
    }
    public class kullaniciBilgileri
    {
        public string ad { get; set; }
        public string soyad { get; set; }
        public string fotograf { get; set; }
    }
}
public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [WebMethod]
    public static string GetSessionValue(string kullaniciAd)
    {
        HttpContext.Current.Session["kullanici"] = kullaniciAd;
        return kullaniciAd;
    }
}

 public partial class Home : System.Web.UI.Page
{       
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["kullanici"] == null)
        {
            Response.Redirect("Login.aspx");
        }
    }

}