Sending a JSON object to an ASP.NET web service using JQUERY ajax function

前端 未结 5 550
闹比i
闹比i 2021-02-09 22:29

I want to create object on the client side of aspx page. And i want to add functions to these javascript classes to make easier the life.

Actually i can get and use the

5条回答
  •  梦毁少年i
    2021-02-09 23:31

    Javascript side:

    JSClass.prototype.fSaveToDB(){
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "/WS/SaveObject.asmx/fSaveToDB"),
    
            data: data: $.toJSON({ _obj: this }),
    
            dataType: "json"
        });
    }
    

    Web service is:

    [WebMethod()]
    public Student fSaveToDB(Student _obj)
    {
        return bla bla bla;
    }
    

提交回复
热议问题