abc abc - 3 months ago 6x
jQuery Question

accessing bulk array values in code behind using ajax

passing values to code behind (cs).I had researched a lot and used this code but it didn't worked for me below is the code that I used what I need is I need to pass values in code behind(CS) but using this code I am getting an error near



function foo() {
var values = ["1,", "2", "3"];

// Make the ajax call
type: "POST",
url: "Default.aspx/Done", // the method we are calling
contentType: "application/json; charset=utf-8",
data: {values : JSON.stringify({ arr: values })},
dataType: "json",
success: function (result) {
alert('Yay! It worked!');
error: function (result) {
alert('Oh no :(');
return false;


<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="false" OnClientClick="return foo();" />


public static void RegisterRoutes(RouteCollection routes)
var settings = new FriendlyUrlSettings();
//settings.AutoRedirectMode = RedirectMode.Permanent;

public static void test(string[] arr)


Though I had an error in code behind I am not getting any error and I am unable to go to code behind even after putting the break point and I am getting a button when I run this code when I click this not happens except the page is getting refreshed each time when I click the button can any one help me out in doing this



 var values = [1, 2, 3];//your array wasn't valid 

 data: {values : values},//you don't need to stringify the values because we have a valid json syntax