Call server side function using $.ajax

前端 未结 2 2039
名媛妹妹
名媛妹妹 2021-01-23 07:00

Ultimately, I\'d like to send a value to the server on a button click and query my DB. For now, I\'m having trouble using jquery.ajax to call a function on the server side. He

2条回答
  •  执念已碎
    2021-01-23 07:27

    http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/ this link could be usefull

    EDIT: your ajax call have to look like this:

     $.ajax(
                {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "ajax.aspx/Test",
                    data: "{ sendData: 'ok' }",
                    success: function (result) { alert("successful!"); }
                })
    

提交回复
热议问题