/    Sign up×
Community /Pin to ProfileBookmark

Processing XMLHttpRequest

Hi,

I am not big on JavaScript (I usually do Java/JSPs), however I am trying to create a solution to the below problem using JavaScript (it is something Java cannot do):

I need to send a request to a url with a custom header in the http request, the response will be of type “application/x-ica” and will return an ica file. All I need to do is launch the citrix application (ica files give you the information you need to do this) as per usual way of dealing with ica files by internet explorer on the client machine.

I havent found a way of submitting an http request with javascript and then telling the browser to deal with the reponse as it normally would (i.e. launch citrix), the response goes into an ‘XMLHttpRequest’ object. I’m not sure how to get the browser to take the reponse and deal with it and launch the citrix application.

I know this is possible by saving the response to a file, then opening the file with something like:

[CODE]function run()
{
var file = “C:\Documents and Settings\jdevine5\Desktop\appica.ica”;
var ws = new ActiveXObject(“WScript.Shell”);
ws.run(“”C:\Program Files\Citrix\ICA Client\wfica32.exe” “C:\Documents and Settings\jdevine5\Desktop\appica.ica””);
}[/CODE]

however for security reasons this isnt an option.

Can anybody suggest a better way of doing this?

For reference my code so far is below (it’s only a test harness, this isn’t the real solution but it replicates the crucial bit):

[CODE]<html>
<body>

<script type=”text/javascript”>

function makeHttpObject()
{
try {return new XMLHttpRequest();}
catch (error) {}
try {return new ActiveXObject(“Msxml2.XMLHTTP”);}
catch (error) {}
try {return new ActiveXObject(“Microsoft.XMLHTTP”);}
catch (error) {}

throw new Error(“Could not create HTTP request object.”);

alert(“blah”);

show(typeof(makeHttpObject()));
}

function go()
{
var url = “http://100.100.100.100:8011/app/servlet?param1=9999”;

var headervar = “token_text”;

var request = makeHttpObject();

request.open(“GET”, url);
request.setRequestHeader(“X-custom”, headervar);

request.send(null);

request.onreadystatechange = function() {
if (request.readyState == 4)
document.write(request.responseText);
};

}

</script>

<input type=”button” value=”MAKE HTTP REQUEST” onclick=”go();”><br><br>

</body>
</html>[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @jjdevine spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...