ASP.NET中的Jquery数据 [英] Jquery datable in ASP.NET

查看:70
本文介绍了ASP.NET中的Jquery数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是jquery数据表的新手。我试图从datatable调用.aspx页面并从webmethod返回json,但我无法从js文件调用aspx页面webmethod。



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"
                },// ajax source                
                "columns": [
                  {},
                  {},
                  {},
                  {},
                  {}
                ],
                "columnDefs": [{ // set default column settings
                    "targets": -1,
                    "data": null,
                    "defaultContent": '<a class="edit" href="">Edit</a>'
                },
                { // set default column settings
                    "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)
            {
            }
        }







出于安全考虑,我更喜欢.aspx webmethod over .ashx和.asmx。请帮帮我。



我尝试过:



从.js文件调用.asmx webmethod但出于安全考虑,我想使用.aspx页面




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

推荐答案

(#tblScratchOffConfig),
dataTable:{
responsive:true,
deferRender:true,
处理:true,
ajax:{
url:../ WebPages /MyDetails.aspx/GetScratchOff,
类型:'GET',
dataType:json
},// ajax source
columns:[
{},
{},
{},
{},
{}
],
columnDefs:[{//设置默认值列设置
targets: - 1,
data:null,
defaultContent:'< a class =edithref =>编辑< / a>'
},
{//设置默认列设置
目标: - 5,
数据:null,
可见:false
}]
}

});
("#tblScratchOffConfig"), dataTable: { "responsive": true, "deferRender": true, "processing": true, "ajax": { url: "../WebPages/MyDetails.aspx/GetScratchOff", type: 'GET', dataType: "json" },// ajax source "columns": [ {}, {}, {}, {}, {} ], "columnDefs": [{ // set default column settings "targets": -1, "data": null, "defaultContent": '<a class="edit" href="">Edit</a>' }, { // set default column settings "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)
            {
            }
        }







出于安全考虑,我更喜欢.aspx webmethod over .ashx和.asmx。请帮帮我。



我尝试过:



从.js文件调用.asmx webmethod但出于安全考虑,我想使用.aspx页面




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


这篇关于ASP.NET中的Jquery数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆