我有一個頁面,用戶在根據這些關鍵字找到資源之前提交了多個關鍵字。我有一個加載所有關鍵字的jQuery數組,我想將該jQuery數組傳遞到下一個結果頁面。我試圖找出最好的方法來做到這一點。我已經嘗試將數組放入字符串並通過URL傳遞,但無法正確URLEncode它。我也嘗試過使用window.location,但這一直效果不佳。這看起來很簡單,但我正在圈圈。這是一個我想保存在內存中的一維數組,然後將它傳遞給下一個aspx頁面。什麼是最好的方法?下面是我的代碼,因爲它現在是不正確的。將jQuery數組傳遞到C#頁面的最佳方法
//When get resources button clicked show current array values
$("#nihSearch_btnResults").click(function() {
//get number of tabs in the holder
gettabs = $("div#keys > div.tab").size();
output = "";
//loop through the tabs
$("div.tab span").each(function() {
//get the text of the tab
var kw = $(this).text();
//add it to the array
keywords.push(kw);
});
var jsonstring = JSON.stringify(keywords);
alert(jsonstring);
});
有你不想使用cookie的一個原因? –
這篇文章怎麼樣?它似乎回答你的問題。 http://stackoverflow.com/questions/320291/how-to-post-an-array-of-complex-objects-with-json-jquery-to-asp-net-mvc-control –
Will,我想我可以使用cookie ......湯姆,這似乎比我想做的更深入。 – Jason