Как отправить данные поста с помощью ajax-запроса через Datatable - PullRequest
0 голосов
/ 26 октября 2018

Я пытался отправить некоторые почтовые данные с помощью ajax-запроса на сервер через таблицы данных, вот мой код

<script type="text/javascript">
    //this is the datatable it brings data in json format from server
    $(document).ready(function() {
        var selected = $("#mainschool_id option:selected").val();
        //alert(selected);
        $('#example').dataTable({
            "bProcessing": true,
            "ajax": {
                "url": "/nvs/system/modules/NVS.NLI/elements/trainingalldatatable.jsp",
                "data": {
                    data: selected
                }

            },
            "sAjaxSource": "/nvs/system/modules/NVS.NLI/elements/trainingalldatatable.jsp",
            "search": {
                "smart": false
            },
            "scrollX": true,
            "aoColumns": [{
                    type: "text"
                },
                {
                    type: "number"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                },
                {
                    type: "text"
                }]
        });
    });
</script>

Но это выдает ошибку ajax, каждый раз, когда я использую. Нет конкретного объяснения для использования таблиц данных с jsp и java. Любая помощь будет очень признательна. Спасибо

1 Ответ

0 голосов
/ 26 октября 2018

Поскольку вы используете два URL-адреса, один из Sajaxsource и другой внутри ajax, вам не нужно использовать ajaxsource в этом случае

<script type="text/javascript">

//this is the datatable it brings data in json format from server
$( document ).ready(function() {
var selected=$("#mainschool_id option:selected").val();
//alert(selected);
$('#example').dataTable({
       "bProcessing": true,
             "ajax": {
            "url": "/nvs/system/modules/NVS.NLI/elements/trainingalldatatable.jsp",
            "data":{data:selected}

            },

               "search": {
                 "smart": false
               },
               "scrollX": true,
       "aoColumns": [
           { type: "text"},
           { type: "number"},
           { type: "text" },
           { type: "text" },
           { type: "text" },
                       { type: "text" },
                       { type: "text" },
                       {type:"text"},
                       { type: "text" },
                       { type: "text" },
                       { type: "text" },
                       {type:"text"},
                        {type:"text"}



              ]
      });
});
</script>

Надеюсь, это поможет, спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...