2011-12-13 44 views
0

下面是我的程序存储一些数据,饼干供以后访问的结构为什么这个cookie返回我空,当我把它从其他函数[IE]

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中。请帮我解决这个问题。

回答

2

尝试:

 
$.cookie('cookie_name', 'our value', { path: '/', expires: 10000 }); 
//then try alerting out of function 
相关问题