title: Call function on page load and again on button click, but with different parameters
body: <p>I have an Ajax function that brings data of a web method and displays it on the page. I want to show the first page with 4 item on page load. When the button is clicked, the next four items should show, and so forth for the next clicks. This executes on page load, but when I click the button nothing happens.</p>
  
  <pre><code> $(document).ready(function () {
          var s;
          var countnumber = 0;
          function dos(s, countnumber) {
  
              participant = s.split("!");
              var i
              for (i = countnumber; i &lt; countnumber + 4; i++) {
                  part = participant[i].split("ٌ");
  
                  rk = part[5];
  
                  if (rk == 1) {
                      $("#ts" + i).attr('src', 'con1.png'); 
                  } else if (rk == 2) {
                      $("#ts" + i).attr('src', 'con2.png');
                  } else if (rk == 3) {
                      $("#ts" + i).attr('src', 'con3.png');
                  } else if (rk &gt; 3 &amp;&amp; rk &lt; 20) {
                      $("#ts" + i).attr('src', 'briliant.ico');
                  } else if (arrlist[5] &gt; 20 &amp;&amp; arrlist[5] &lt; 50) {
                      $("#ts").attr('src', 'cup.png');
                  } else {
                      $("#ts" + i).attr('src', 'box.png');
                  }
                      { $("#st" + i) }
                      $("#use" + i).html(part[1]);
                      $("#rnk" + i).html(part[5]);
                      $("#avg" + i).html(part[2]);
                      $("#pnt" + i).html(part[4]);
                      $("#wit" + i).html(part[3]);
                      $("#kl" + i).html(part[0]);
                      $("#use" + i).html(username);
                  }
  
          }
          $('#kil').bind('click', function () {
              countnumber = countnumber + 4;
              dos(s , countnumber);
          })
  
          var arrlist;
          var participant, part;
          var username, klll, wt, pt, av, rk;
  
  
          $.ajax({
              type: "POST",
              url: "rank.aspx/bringdata",
              data: "",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              async: true,
              cache: false,
              success: function (ret) {
                  s = ret.d;
                  dos(s, 0);
              },
              error: function (x, e) {
                  alert("error");
              }
          });
      });
  </code></pre>