Hi I'm new to jquery datatables. I am trying to call .aspx page from datatable and return json from webmethod but i'm not able to call aspx page webmethod from js file.
var initTable1 = function () {
var grid1 = new Datatable();
grid1.init({
src: $("#tblScratchOffConfig"),
dataTable: {
"responsive": true,
"deferRender": true,
"processing": true,
"ajax": {
url: "../WebPages/MyDetails.aspx/GetScratchOff",
type: 'GET',
dataType: "json"
},
"columns": [
{},
{},
{},
{},
{}
],
"columnDefs": [{
"targets": -1,
"data": null,
"defaultContent": '<a class="edit" href="">Edit</a>'
},
{
"targets": -5,
"data": null,
"visible": false
}]
}
});
<pre lang="c#">
<pre> [System.Web.Services.WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static void GetScratchOffXML()
{
try
{
HttpContext.Current.Response.Write(json);
}
catch (Exception ex)
{
}
}
I prefer .aspx webmethod over .ashx and .asmx for security reasons. Please help me in this.
What I have tried:
Calling .asmx webmethod from .js file but for security reasons i want to use .aspx page