Cable Forum

Cable Forum (https://www.cableforum.uk/board/index.php)
-   General IT Discussion (https://www.cableforum.uk/board/forumdisplay.php?f=19)
-   -   XMLHttpRequest (https://www.cableforum.uk/board/showthread.php?t=33622904)

Mr_love_monkey 25-10-2007 13:07

XMLHttpRequest
 
Ok, I'm stumped - and maybe someone here will know.

I've written a simple XMLRPC client in javascript, using XMLHttpRequest - and this works, I can contact the server, make an RPC, and get a result back - hurrah.

Now my problem comes from trying to pass in a cookie into the request

I do
Code:

request.setRequestHeader('Cookie','aParam=aValue');
which works in Firefox - however in IE7, it doesn't. There used to be a bug where you had to set the cookie twice for it to register in IE, but that doesn't work here.
I'm not getting an error, the cookies just aren't being passed through to the server.
I've tried the ActiveX version of XMLHttpRequest, as well as the new native version in IE7 - both have the same result - I've googled a fair bit but haven't found any answers....

Acathla 25-10-2007 15:01

Re: XMLHttpRequest
 
The cookie bug in xmlDOM ignores the first command of setRequestHeader and as far as I know, I used the format as below - not with brackets. Dunno if that makes any difference at all but maybe worth a try?

request.setRequestHeader "Cookie", "aParam=aValue"
request.setRequestHeader "Cookie", "aParam=aValue"

Aren't you like supposed to use Set-Cookie now anyway?

Mr_love_monkey 25-10-2007 15:10

Re: XMLHttpRequest
 
Quote:

Originally Posted by Acathla (Post 34421384)
The cookie bug in xmlDOM ignores the first command of setRequestHeader and as far as I know, I used the format as below - not with brackets. Dunno if that makes any difference at all but maybe worth a try?

request.setRequestHeader "Cookie", "aParam=aValue"
request.setRequestHeader "Cookie", "aParam=aValue"

Aren't you like supposed to use Set-Cookie now anyway?

That's not javascript though is it? - probably vbscript.
And Set-cookie is done on the server side, whereas I'm passing it into an xmlhttprequest.

Acathla 25-10-2007 16:17

Re: XMLHttpRequest
 
oh yeah doh. i forgot i code in vbscript :()

if i come across anything I'll let you know.

Graham M 25-10-2007 16:18

Re: XMLHttpRequest
 
That's the precise trouble with all of these niche Client-Side languages!!!

Mr_love_monkey 25-10-2007 16:21

Re: XMLHttpRequest
 
Quote:

Originally Posted by Zeph (Post 34421452)
That's the precise trouble with all of these niche Client-Side languages!!!

I'd hardly call javascript (or vbscript) a niche language...

Graham M 25-10-2007 16:21

Re: XMLHttpRequest
 
They are! They have their own little niches with their own niche users, like yourselves :D OK perhaps going a bit overboard calling Javascript a niche language, but I know of many more Javascript coders than I do VB?

Mr_love_monkey 25-10-2007 16:30

Re: XMLHttpRequest
 
Quote:

Originally Posted by Zeph (Post 34421462)
They are! They have their own little niches with their own niche users, like yourselves :D OK perhaps going a bit overboard calling Javascript a niche language, but I know of many more Javascript coders than I do VB?

certainly there's less vbscript people out there now, but a lot of places do still use vbscript.

Graham M 25-10-2007 16:32

Re: XMLHttpRequest
 
Does it have any advantages over JScript?

Mr_love_monkey 25-10-2007 16:57

Re: XMLHttpRequest
 
Quote:

Originally Posted by Zeph (Post 34421475)
Does it have any advantages over JScript?

personally I don't think it does, on the web side of things - especially since not all browsers support it - but I'm sure someone will disagree with me :)

Personally I've never been a big fan of it, since I learnt javascript first, and got exposed to vbscript through a rather nasty project involving web based version control - but as I say, lots of people still use it

Hugh 25-10-2007 19:17

Re: XMLHttpRequest
 
"Danger, Will Robinson!"

“Warning! Warning! Geeks in immediate vicinity” ........ ;)

[img]Download Failed (1)[/img]https://www.cableforum.co.uk/images/local/2007/10/9.jpg

Graham M 25-10-2007 19:18

Re: XMLHttpRequest
 
Without Geeks you'd still be carrying stuff rather than using one of those handy "WHEEL" devices :p

Hugh 25-10-2007 19:21

Re: XMLHttpRequest
 
Quote:

Originally Posted by Zeph (Post 34421697)
Without Geeks you'd still be carrying stuff rather than using one of those handy "WHEEL" devices :p

You're confusing geeks with engineers.... ;)


btw, I am in charge of 135 geeks, so I know of what I speak..... :D

Graham M 25-10-2007 19:28

Re: XMLHttpRequest
 
Engineers are just a subclass of geek :p:

Mr_love_monkey 25-10-2007 22:16

Re: XMLHttpRequest
 
Quote:

Originally Posted by foreverwar (Post 34421693)
"Danger, Will Robinson!"

“Warning! Warning! Geeks in immediate vicinity” ........ ;)

http://www.desunited.no.sapo.pt/woody.jpghttps://www.cableforum.co.uk/images/local/2007/10/9.jpg

Shut yer face! :p: :)

Mr_love_monkey 26-10-2007 11:38

Re: XMLHttpRequest
 
for those of you that care...

to get around this what I have done is just have the client code add in the cookie, and add in the value as a seperate request header, i.e.:
Code:

      request.setRequestHeader("Cookie","aParam=aValue");
      request.setRequestHeader("aParam","aValue");

and then on the server side, we check for the cookie first, if it's not there we look the for request header and use that.
It's a hack, and offends me, but hey, what can you do?

Acathla 26-10-2007 11:58

Re: XMLHttpRequest
 
You Sold Out!

Mr_love_monkey 26-10-2007 12:04

Re: XMLHttpRequest
 
Quote:

Originally Posted by Acathla (Post 34422227)
You Sold Out!

I know, I know - it used to be about the code man! - but I've changed, and sold out - now it's just about getting the job done.
Sometimes I don't even know who I am any more.


All times are GMT +1. The time now is 04:52.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
All Posts and Content are Cable Forum