Hi all.
I'm using JavaScript to call a server side service provided by an IBMBPM Tool (Lombardi teamworks), to retrieve an XML object.
I've stripped it down to the bare essentials below.
When I click on the button, it runs the call 5000 times.
Any browser grabs a whole load of memory and never lets go of it. What Am I doing wrong here?
The code is below.
Code:
<script>
function makeRequest(url, params, callBack) {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
// See note below about this line
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
callBack(http_request.responseText);
} else {
alert('There was a problem with the request.');
}
}};
http_request.open('GET', url, true);
http_request.send(params);
}
tw.coach.callServiceRegus = function(service, params, callBack, snapshot) {
if(snapshot == "" || snapshot == null) {
// coachSnapshotContext is injected via the CoachDesigner.xsl
snapshot = coachSnapshotContext;
}
var url = "/portal/jsp/callService.do?serviceName=" + service + "&snapshotId=" + snapshot;
makeRequest(url, params, callBack);
};
function getTickets(){
var data;
var inputVar = '<input><variable name="inputVar">dion.jones</variable>'
inputVar += '<variable name="sortOrder">t.Priority, t.CreateDate</variable>'
inputVar += '<variable name="displayType">UserLandingPage</variable>'
inputVar += '</input>';
tw.coach.callServiceRegus('SORGetUserTicketsXML',
inputVar,
function(data){
}
);
}
function explode(){
for (var i = 0 ; i < 5001 ; i++) {
getTickets();
}
alert("done");
}
</script>
This button is in the HTML on the page.
<!-- Refrech Button -->
<input type="button" onclick="explode();" value="clickerty-Click!" />