Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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
Jquery 内部服务器错误ajax asp.net_Jquery_Asp.net_Ajax - Fatal编程技术网

Jquery 内部服务器错误ajax asp.net

Jquery 内部服务器错误ajax asp.net,jquery,asp.net,ajax,Jquery,Asp.net,Ajax,您好,我正在编写一个ajax代码,该代码使用web服务从数据库服务器获取数据,但每次尝试获取数据时都会出现错误:内部服务器错误 我在这里做错了什么 $.ajax({ type: "POST", url: "CreerEquipe.aspx/GetFrmtionShema", data: "{'id':'" + parseInt(id) + "','formation':'4-4-2'}",

您好,我正在编写一个ajax代码,该代码使用web服务从数据库服务器获取数据,但每次尝试获取数据时都会出现错误:内部服务器错误

我在这里做错了什么

$.ajax({
       type: "POST",
                url: "CreerEquipe.aspx/GetFrmtionShema",
                data: "{'id':'" + parseInt(id) + "','formation':'4-4-2'}",
                dataType: "json",
                contentType: "application/json;charset=utf-8",
                success: function (res) {
                    alert(res.d);

                    $('.formation').html(res.d);
                    //alert(schema);

                    //$("#TotalDEF").html("(" + Count + "/5)");
                },
                error: function (xhr, status, error) {
                    alert('Error : ' + error);
                }
            });
webmethode中的另一面:

        [WebMethod]
        [ScriptMethod]
        public static string GetFrmtionShema(int id,string formation)
        {
            string data = "";
            ConGeters Config = new ConGeters();
            Config.Cmd = new SqlCommand("select * from tbl_Formation where id_formation = @id", Config.con);

            Config.Cmd.Parameters.AddWithValue("@id", id);
            //Config.Cmd.CommandType = CommandType.StoredProcedure;
            Config.Open();
            Config.Dr = Config.Cmd.ExecuteReader();
            while (Config.Dr.Read())
            {
                data = Config.Dr[4].ToString();
            }
            Config.Close();
            Config.Dr.Close();
            return data;
        }

有什么建议吗?我被封锁了两天

朋友,不要用字符串连接来传递参数。试试这个:

$.ajax({
       type: "POST",
                url: "CreerEquipe.aspx/GetFrmtionShema",
                data: JSON.stringify({ id: parseInt(id), formation: '4-4-2' }),,
                dataType: "json",
                contentType: "application/json;charset=utf-8",
                success: function (res) {
                    alert(res.d);

                    $('.formation').html(res.d);
                    //alert(schema);

                    //$("#TotalDEF").html("(" + Count + "/5)");
                },
                error: function (xhr, status, error) {
                    alert('Error : ' + error);
                }
            });

我检查了您对服务器的ajax请求是否正常。我认为您应该检查您的代码,而不使用它是否工作的方法。当代码有错误时,会出现内部服务器错误。检查你的代码

`ConGeters Config = new ConGeters();
            Config.Cmd = new SqlCommand("select * from tbl_Formation where id_formation = @id", Config.con);

            Config.Cmd.Parameters.AddWithValue("@id", id);
            //Config.Cmd.CommandType = CommandType.StoredProcedure;
            Config.Open();
            Config.Dr = Config.Cmd.ExecuteReader();
            while (Config.Dr.Read())
            {
                data = Config.Dr[4].ToString();
            }
            Config.Close();
            Config.Dr.Close();`

您得到的具体错误是什么?检查Visual Studio中的“输出”选项卡以获取堆栈跟踪。您传递了一个队列,但从未在服务器端使用它。。。数据:“{'id':'”+parseInt(id)+','formation':'4-4-2'}”,公共静态字符串GetFrmtionShema(int-id,字符串formation)