Storing cookie session data to Jquery using AJAX (Wihout PHP)

笑着哭i 提交于 2019-12-24 16:10:44

问题


Having a tough time finding clear information if this is even possible. I am currently running on Sharepoint 2010. Working on a page using the REST method that uses AJAX. I was wondering if there's a way to be able to identify whos logged in? My first reaction was to look for a way to get the cookies session data using AJAX and Jquery. That Adventure didn't last too long.

I was scanning trough the network data of an existing sucessul AJAX request i have on my page. Would there be a way to piggy back trough this same request and ask to provide me the request header's cookie data?

loadActiveIncidents: function () {
        $.ajax({
            url: this.basePath() + '/PROD_Incidents?$filter=ÉtatValue%20ne%20%27Fermé%27&$orderby=PrioritéValue desc',
            dataType: 'json',
            cache: false,
            success: function (data) {

                $.each(data.d.results, function (index, incident) {

                $('#example tbody').append(
                "<tr>" +
                "<td class='over_flow_control'> <button class='edit_button btn btn-default btn-sm' name ='btnSubmit' type='button' value='Edit' data-ID='"+incident.ID+"'><i class='glyphicon glyphicon-edit'></i></button></td>" +
                "<td class='over_flow_control'>" + incident.Incident + "</td>" +
                "<td class='over_flow_control'><h4><span class='priorité_span'>" + incident.PrioritéValue + "</span></h4></td>" +
                "<td class='over_flow_control'>" + incident.Composante + "</td>" +
                "<td class='over_flow_control text-left'>" + incident.Description + "</td>" +
                "<td class='over_flow_control Date_de_début_cell'>" + incident.Date_de_début + "</td>" +
                "<td class='over_flow_control'>" + incident.ResponsableValue + "</td>" +
                "</tr>");   
                })
                IncidentManager.table_conditional_format();
                $('#loading').hide("slow");
                $('#example').show("slow");
            }
        });
    },

回答1:


I think you may use https://github.com/carhartl/jquery-cookie

You can then do: $.cookie('mycookie', 'mycookievalue');

To delete: $.removeCookie('mycookie');



来源:https://stackoverflow.com/questions/34080851/storing-cookie-session-data-to-jquery-using-ajax-wihout-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!