2cf97071e96ffb64721133cd1f9dedf0195dac8e
FAQ/getting-reportlist-information.md
| ... | ... | @@ -44,7 +44,7 @@ Here is an example of an AJAX request you can send in order to return the Report |
| 44 | 44 | |
| 45 | 45 | - rs.aspx?wscmd=reportlistdatalite |
| 46 | 46 | |
| 47 | -_**In this case you could use JSON data to populate a client-side control using javascript like so:**_ |
|
| 47 | +_**In this case you could use the JSON data to populate a client-side control using javascript like so:**_ |
|
| 48 | 48 | |
| 49 | 49 | ```javascript |
| 50 | 50 | function GetReports(keyword, category) { |
| ... | ... | @@ -54,6 +54,55 @@ _**In this case you could use JSON data to populate a client-side control using |
| 54 | 54 | requestString += '&wsarg0=' + category + '&wsarg1=' + keyword + '&wsarg2=1'; |
| 55 | 55 | AjaxRequest('./rs.aspx', requestString, AcceptReports, GetReportsFail, 'reportlistdatalite'); |
| 56 | 56 | } |
| 57 | + |
|
| 58 | + function AcceptReports(returnObj, id, parameters) { |
|
| 59 | + for (var rCnt1 = 0; rCnt1 < returnObj.ReportSets.length; rCnt++) { |
|
| 60 | + $("#ReportsDropdown").append($('<option></option>').val(returnObj.ReportSets[rCnt].Name).html(returnObj.ReportSets[rCnt].Name)); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + //Ajax request for JSON methods----------------------------------------------------------- |
|
| 65 | + function AjaxRequest(url, parameters, callbackSuccess, callbackError, id) { |
|
| 66 | + var thisRequestObject = null; |
|
| 67 | + if (window.XMLHttpRequest) |
|
| 68 | + thisRequestObject = new XMLHttpRequest(); |
|
| 69 | + else if (window.ActiveXObject) |
|
| 70 | + thisRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); |
|
| 71 | + thisRequestObject.requestId = id; |
|
| 72 | + thisRequestObject.onreadystatechange = ProcessRequest; |
|
| 73 | + |
|
| 74 | + thisRequestObject.open('GET', url + '?' + parameters, true); |
|
| 75 | + thisRequestObject.send(); |
|
| 76 | + |
|
| 77 | + function DeserializeJson() { |
|
| 78 | + var responseText = thisRequestObject.responseText; |
|
| 79 | + while (responseText.indexOf('"\\/Date(') >= 0) { |
|
| 80 | + responseText = responseText.replace('"\\/Date(', 'eval(new Date('); |
|
| 81 | + responseText = responseText.replace(')\\/"', '))'); |
|
| 82 | + } |
|
| 83 | + if (responseText.charAt(0) != '[' && responseText.charAt(0) != '{') |
|
| 84 | + responseText = '{' + responseText + '}'; |
|
| 85 | + var isArray = true; |
|
| 86 | + if (responseText.charAt(0) != '[') { |
|
| 87 | + responseText = '[' + responseText + ']'; |
|
| 88 | + isArray = false; |
|
| 89 | + } |
|
| 90 | + var retObj = eval(responseText); |
|
| 91 | + if (!isArray) |
|
| 92 | + return retObj[0]; |
|
| 93 | + return retObj; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + function ProcessRequest() { |
|
| 97 | + if (thisRequestObject.readyState == 4) { |
|
| 98 | + if (thisRequestObject.status == 200 && callbackSuccess) { |
|
| 99 | + callbackSuccess(DeserializeJson(), thisRequestObject.requestId, parameters); |
|
| 100 | + } |
|
| 101 | + else if (callbackError) { |
|
| 102 | + callbackError(thisRequestObject); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 57 | 106 | ``` |
| 58 | 107 | ------ |
| 59 | 108 |