问题
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