簡體   English   中英

ajax POST 問題 - 500 內部服務器錯誤

[英]ajax POST problem - 500 internal server error

我在運行我的項目時遇到問題。 當我運行該項目時,我得到了 500 台內部服務器。

我的代碼:

客戶端.cs

public class Client
    {
        public Client(string firstName, string id, string lastName)
        {
            FirstName = firstName;
            LastName = lastName;
            Id = id;
        }
        [JsonProperty("id")]
        public string Id { get; set; }
        [JsonProperty("first_name")]
        public string FirstName { get; set; }
        [JsonProperty("last_name")]
        public string LastName { get; set; }
       
    }

在 Regrestion.aspx 文件中,當函數 Regestion 工作時 - 然后我總是得到 500 錯誤

 <script type="text/javascript" language="javascript">
        function Regrestion() {

            //get data by document.getElementById...
            var d = {
                first_name: firstName,
                id: id,
                last_name: lastName
            }
            $.ajax({
                url: 'Registretion.aspx/AddNewClient',
                method: "POST",
                contentType: "application/json; charset=utf - 8",
                dataType: 'json',
                data: JSON.stringify(d),
                success: function (flights) {
                    alert("succ");
                }, error: function (error) {
                    alert("error");
                }
            });
        }
    </script>

Registry.aspx.cs 背后的代碼

 public partial class Registretion : System.Web.UI.Page
    {
          
        [System.Web.Services.WebMethod(EnableSession = true)]
        [System.Web.Script.Services.ScriptMethod]
        public static Client AddNewClient(Client c)
        {
          //more  code
            return c;
        }

500 internal server error表示服務器響應錯誤。 后端(您的服務器端)存在一些問題。

它與 JavaScript 或 AJAX 無關。 這也不是連接問題。

查看您的代碼:在您的Registry.aspx.cs文件末尾是否缺少}括號?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM