以下是我的程序结构,用于将一些数据存储在cookie中供以后访问
function xmlSet()
{
var qTypes = ["Single","Multi","Grid","Open","Grid3D"];
for(var i = 0;i<qTypes.length;i++)
{
SingleReader(qTypes[i]);
}
}
和
function SingleReader(eleType)
{
var xmlDat = $.parseXML($('#xmlText').val());
var xml = $(xmlDat);
var path = xml.find('ProjectID').text();
xml.find(''+eleType+'').each(function(){
var id = $(this).attr('name');
var dat = $(this).text('');
$.cookies.set(id,dat);
//Here I am testing whether cookie is being stored or not
alert($.cookies.get(id)); // Returns value which was before.
};
alert($.cookies.get("M")) // Here "M" is known Item but it returns me null when I access outside the function
}
这仅在IE中发生。请帮帮我,
答案 0 :(得分:2)
尝试:
$.cookie('cookie_name', 'our value', { path: '/', expires: 10000 }); //then try alerting out of function