2012-10-17 23 views
0

好日子了jQuery的Ajax功能發送localStorage的變量,通過沒有它的URL爲

我只是想知道,如果沒有通過Ajax的功能,沒有它的網址是發送localStorage的變量的方法。例如:

$.ajax({ 
    type: "POST", 
    url: "../pages/profile.php", 
    data: localStorage.email, 
    dataType: 'json' 
    success: function(result) 
    {  
     //document.location.replace('../pages/main.php'); 
    }, 
    error: function() 
    { 
     alert('An Error has occured, please try again.'); 
    } 
}); 

根據需要,PHP的返回類型將是JSON。

在此先感謝

回答

1

變化

data: localStorage.email, 

data: {email: localStorage.getItem('email')} 

從而使data是正確的JSON格式,並使用(我相信)正確的方法來檢索項從localStorage

+0

謝謝,它似乎在工作 – Crossman

相關問題