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
There are a couple of things which are not quite correct:
Full example:
function send() {
$.ajax({
type: "POST",
url: "ajax.aspx/Test",
data: '{ sendData: "ok" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) { alert("successful!" + result.d); }
});
}
This code works for me.
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!"); }
})