Updated: jQuery to C# – AJAX (with data)

public static string testingWebMethod(string name) {

  //Do something with name? 

  string someString = "Woah";

  return someString;
var dataToSend = JSON.stringify({
  "name": "foo"

  type: "POST",
  url: "page.aspx/testingWebMethod",
  dataType: "json",
  data: dataToSend,
  contentType: "application/json",
  success: function(response) {
  error: function(err) {

Testing Javascript and jQuery array loops

(by axds)


The simple for loop seems to win the speed tests:

let arrLen = test.length; for( let i = 0; i < arrLen; i++ ){  }

Although this method is less DRY as the length of the the array has to be known. JS’s forEach() or jQuery’s $.each() are good alternatives that are dynamic.

The clear worst is the ‘for x in y’ loop. Which has bulky syntax and is slow.