Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have used JQuery to get results from a database and populate a UL on a page with the items. Is this what you were looking for?</p> <p>Javascript</p> <pre><code> //Set up Approve Requests Page $("#approveRequests").bind('pageAnimationEnd', function () { getRequestList(); return false; }); //Gets the list of requests function getRequestList() { // call server-side webmethod using jQuery $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Index.aspx/GetOrdersForApproving", data: "{ }", // send an empty object for calls with no parameters dataType: "json", success: displayRequests, failure: reportError }); } //displays the requests in the ul function displayRequests(result) { // ASP.NET encapsulates JSON responses in a property "d" if (result.hasOwnProperty("d")) { result = result.d; } // iterate through player list and add info to the markup var ul = $("#requestsForApproval"); for (i = 0; i <h2>" + result[i].Supplier + "</h2>," + result[i].Description + "," + result[i].Value + "</li>"); var li = $("" + "<h3>" + result[i].OrderID + " - " + result[i].Supplier + "</h3>" + "" + "" + result[i].Description + "" + " " + "" + "" + "" + "Quant: " + result[i].Quantity + "" + "" + "Price: " + result[i].UnitPrice + "" + "" + "Total: " + result[i].Value + "" + "" + "" + "" + " " + "<ul>Approve</li>" + "Reject</li></ul>" + "" + "" + "</li>"); ul.append(li); } </code></pre> <p>ASPX</p> <pre><code> /// /// Gets a list of Request Lines /// /// List of order lines [WebMethod] public static List GetOrdersForApproving() { try { List Lines = new List(); foreach (Objects.Database.OrderLine oOrderLine in Objects.Database.OrderLine.GetLinesWaitingFor(StaticStore.CurrentUser.UserID, int.MinValue)) { Lines.Add(new iOrderLine(oOrderLine)); } return Lines; } catch (Exception) { throw; } } </code></pre> <p>The bit that code me struggling to get this working was:</p> <pre><code>if (result.hasOwnProperty("d")) { result = result.d; }</code></pre>
 

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