View Full Version : javascript arrays

07-13-2005, 06:08 PM
i need to send a set of project names from a javascript web page to a C# web service using the url.
one option is get these project names into an array in order to make the URL shorter.

how can i send this string array?
do i have to serialize it?
or how can i send this set of names is there any other suggestion??
any help would be apreciate, thank's in advance.

08-08-2005, 01:37 PM
I'm assuming the array is less than 2k in size? If it is, you can pass it via a querystring using AJAX something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url) {
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = xmlhttpChange;
else if (window.ActiveXObject) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
if(xmlhttp) {
xmlhttp.onreadystatechange = xmlhttpChange;

function xmlhttpChange() {
if(xmlhttp.readyState==4) {
if (xmlhttp.status==200) {
} else {
alert("error sending data");

function sendMe() {
var a = ["foo", "bar", "tik", "wib"];
for(var i=0; a[i]; i++) {
a[i] = escape(a[i]);
var url = "http://www.myDomain.com/myWebService?"+a.join(",");


<input type="button" value="send array" onclick="sendMe();">

Hope this helps


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum