简体   繁体   English

使用AJAX(Wihout PHP)将cookie会话数据存储到Jquery

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

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. 我目前正在SharePoint 2010上运行。使用使用AJAX的REST方法在页面上工作。 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. 我的第一个反应是寻找一种使用AJAX和Jquery获取cookie会话数据的方法。 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. 我正在浏览页面上现有的成功AJAX请求的网络数据。 Would there be a way to piggy back trough this same request and ask to provide me the request header's cookie data? 是否有一种方法可以通过相同的请求并要求向我提供请求标头的cookie数据?

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");
            }
        });
    },

I think you may use https://github.com/carhartl/jquery-cookie 我认为您可以使用https://github.com/carhartl/jquery-cookie

You can then do: $.cookie('mycookie', 'mycookievalue'); 然后,您可以执行以下操作:$ .cookie('mycookie','mycookievalue');

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM