By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,483 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,483 IT Pros & Developers. It's quick & easy.

Problems with javascript location.href

P: n/a
Hi guys,

i have a really stupid problem with this line of code:
location.href = "showreport.php?id=" + sText;

sText is an id of a job that's running on the server.

Showreport.php retrieves the job and outputs the result in HTML. At the same
time job is removed from the server.

What happens is that some browsers (IE 6 mostly) like to GET the
showreport.php TWICE. Of course the second time there is no job any more and
the result returned is of zero length, which is very unpleasant ;-)

Headers sent by the browsers are (1st call):
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, */*
Accept-Language: sl
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322)
Host: veliswork
Connection: Keep-Alive
Cookie: PHPSESSID=tsghl22ijg4f6ba7a2mthggun6

Headers sent by the browsers are (2nd call):
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322)
Host: veliswork
Connection: Keep-Alive
Cookie: PHPSESSID=tsghl22ijg4f6ba7a2mthggun6

Note the Accept tag.
What's even more interesting, the accept tag of IE 6.0 that does not request
twice is:
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*

Note the (still) absent application/pdf, which is the target content here.

Can somebody explain to me, why two calls and if that can be prevented. I
can reduce the problem by keeping the job for another minute or so, but
these jobs tend to be rather large (>10MB RAM usage) when large reports are
generated.

Thanks,
Jure
Oct 5 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Jure Erznoznik wrote:
Hi guys,

i have a really stupid problem with this line of code:
location.href = "showreport.php?id=" + sText;

What calls that?
A link?
If you're using a link href/onclick combo, you need to return false so
the href isn't followed.


Can somebody explain to me, why two calls and if that can be prevented.


Why doesn't the PHP that does the work check for valid ID?
It really should. Good coding practice, less errors, and less chance of
injection attacks or the like.

Oct 5 '05 #2

P: n/a

"nikki" <ka*******@yahoo.com> wrote in message
news:11********************@g44g2000cwa.googlegrou ps.com...

Jure Erznoznik wrote:
Hi guys,

i have a really stupid problem with this line of code:
location.href = "showreport.php?id=" + sText;


What calls that?
A link?
If you're using a link href/onclick combo, you need to return false so
the href isn't followed.


Actually it's a <A> with href set to "javascript:userrep('user')"
The function does return false, but i don't really see the relevance.

Can somebody explain to me, why two calls and if that can be prevented.


Why doesn't the PHP that does the work check for valid ID?
It really should. Good coding practice, less errors, and less chance of
injection attacks or the like.


PHP does check for valid ID. That's why the second result is zero length.

Jure
Oct 6 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.