简体   繁体   中英

How to pass a string array from javascript to asp.net webservice?

I am creating Google Chrome Extension Project. I have a string array and I want to pass this array to my web service and take the array again. How can I do this? Should I need a database for this or I can communicate directly between them?

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;
        }
}

}

It's recommended to have a look at Getting Started AJAX , code would be something like the following

var yourArray = [,];
$.post(url, { data: yourArray}, function (response) {
    // your callback here
}, "text");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM