Note that there are some explanatory texts on larger screens.

plurals
  1. POReturn string array from asp.net web service to jquery
    primarykey
    data
    text
    <p>I have a web service which returns a string currently and I want it to return a string array. My js code looks like this:</p> <pre><code>function getMenu(menuID) { $("#open").css('display', 'block'); $("#close").css('display', 'none'); $('#flash_container').flash({ swf: 'mainGallery.swf', width: "100%", height: 330, wmode: "transparent", quality: "high", flashvars: { XMLFile: 'xml/' + menuID + '.xml' } }); $("div#panel").slideUp("slow", function() { var language; if (getParameterByName('language') == 'en') language = 1; else language = 0; GetMenu.CreateMenu(menuID, language, OnGotMenu, OnFail, "XmlDocument"); }); } function OnGotMenu(result) { var lblOutput = document.getElementById("lblOutput"); lblOutput.innerHTML = result; $(".MenuList a:last").removeAttr('border-left'); $("div#panel").slideDown("slow"); $("#open").css('display', 'none'); $("#close").css('display', 'block'); fleXenv.fleXcrollMain("panel_content"); } </code></pre> <p>Now I return a string. I want to return string[].</p> <p>How do I need to modify my js code to use this array?</p> <p><strong>Edit:</strong> Here is the c# code after the change proposed by @pukipuki (only the relevant part)</p> <pre><code>table.RenderControl(tw); string retVal = "[\"" + menuDIV + sb.ToString() + "\", \"" + currTitle + "\"]"; return retVal.ToString(); </code></pre> <p>Maybe I'm doing something wrong here.</p> <p><strong>Edit 2:</strong> Better version of the c# code:</p> <pre><code>table.RenderControl(tw); retArray[0] = menuDIV + sb.ToString(); retArray[1] = currTitle; string retVal = jsSer.Serialize(retArray); return retVal; </code></pre> <p>But I still don't get an array I can access like:</p> <pre><code>var that = result[0]; var oranother = result[1]; </code></pre> <p>etc.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload