我正在创建Google Chrome扩展项目。我有一个字符串数组,我想将此数组传递给我的Web服务并再次获取该数组。我怎样才能做到这一点?我是否需要一个数据库,或者我可以直接在它们之间进行通信?
function myFunction(selectedText) {
var selected = selectedText.selectionText;
var yenidizi = new Array();
var words = new Array(); // This is my array and I want to pass this array to my web service.
for (var i = 0; i < words.length; i++)
{
for (var j = 0; j < words[i].length; j++)
{
var newstring = words[i];
var temp = null;
words[i] = temp;
temp = newstring;
words[i] = temp;
newstring = null;
}
}
}
答案 0 :(得分:0)
建议您查看Getting Started AJAX,代码类似于以下内容
var yourArray = [,];
$.post(url, { data: yourArray}, function (response) {
// your callback here
}, "text");