title: How can I call a Stored Procedure in Javascript/Ajax?
body: <p>I've got the following code block within a larger javascript file. It uses an API to get the strCategoryID value and returns a list of three document names with appropriate links. works fine except that I need to sort the documents by date of input. I have a stored procedure in the SQL database that gives me what I need but I'm not sure how to make that call and populate the loop with the sorted documents. I'm modifying someone else's code and am pretty new to ajax.</p>
  
  <pre><code>    var list = "&lt;ul style=\"list-style: none; text-indent: -1.2em;\" class=\"news-list\" id=\"news-" + strCategoryID + "\"&gt;";
      $.ajax({
      type: "POST",
      async: false,
      data: strParams,
      url: "/Utilities/AJAXUtilities.aspx",      
      success: function(msg){
      msg = $.createXMLDocument(msg);      
      var li_count = 0;
  
      $(msg).find('CONTENT_SEARCH').each(function(){
  
          if ($(this).find("CNT_AVAILABLE").text() == "T") {
          var title = $(this).find("CNT_TITLE").text();
          var trimtitle = title.substring(0,39);
          list = list.concat("&lt;li&gt;&lt;a href=\"/Content/MyOptions.aspx?id=" + $(this).find("CNT_CONTENT_ID").text() + "\"&gt;" + trimtitle + "...&lt;/a&gt;&lt;/li&gt;&lt;hr&gt;");   
              li_count = li_count+1;
              if (li_count == 3) {
              return false;
              }
          }
      }); 
  
      }
      });
  
      list = list.concat("&lt;/ul&gt;");
      list = list.concat("&lt;br /&gt;&lt;a href=\"\"&gt;View previous news releases&gt;&gt;&lt;/a&gt;");     
      $("#newscatlist").append(list);
      return list;
  </code></pre>