Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpRequest.status) on several configurations

R

R.Manikandan

Hi All,

This topic is already existing in the group but i was not able to add
reply to the existing one, since it has crossed 30 days.

Anyway, i came across the same error and have modified the code from

<a href = "" onClick = "Javascript:somename( );">somename</a>"

to

<a href = "javascript:void(0);" onClick = "Javascript:somename(
);">somename</a>"

In somename( ) fn i am using AJAX to retrieve the value and whenever i
click on that link [old code] it takes me to current page itself
without giving any AJAX response, that too only in Mozilla browser.

After that i changed the href attribute value to "javascript:void(0);"
and it works well without any error.

So this is the situation i came across. I dont know whether the above
info will help you guys?
 
R

Randy Webb

R.Manikandan said the following on 9/7/2006 8:11 AM:
Hi All,

This topic is already existing in the group but i was not able to add
reply to the existing one, since it has crossed 30 days.

Anyway, i came across the same error and have modified the code from

<a href = "" onClick = "Javascript:somename( );">somename</a>"

to

<a href = "javascript:void(0);" onClick = "Javascript:somename(
);">somename</a>"

In somename( ) fn i am using AJAX to retrieve the value and whenever i
click on that link [old code] it takes me to current page itself
without giving any AJAX response, that too only in Mozilla browser.

All other browsers should do the same thing as well as you are not
canceling navigation.
After that i changed the href attribute value to "javascript:void(0);"
and it works well without any error.

So this is the situation i came across. I dont know whether the above
info will help you guys?

Your "solution" has some flaws in it though. The use of javascript: is a
bad use in the HREF of an A element. The FAQ Entry for it was just
posted a day or two ago.

<a href="somewhereMeaningful.html" onclick="somename();return false">

Or:

<button onclick="somename()">Get the Data</button>

The return false is what stops the navigation that you were seeing where
it went to the same page again.

<URL: http://jibbering.com/faq/#FAQ4_24>
 
S

Sawi

Randy Webb napisał(a):
In somename( ) fn i am using AJAX to retrieve the value and whenever i
click on that link [old code] it takes me to current page itself
without giving any AJAX response, that too only in Mozilla browser.

All other browsers should do the same thing as well as you are not
canceling navigation.

Not exactly - it's a bug in some builds of Firefox.
 
M

Mani

The "#" is basically a do nothing for those instances where
it really does not make sense to go anywhere. It's also handy when
developing code as an error in the code would cause the link to be
fallowed, which is probably not what we want when trying to track down
errors.

I think using "#" in href attribute will act similar to "Javacript:
void(0)" function.
 
L

Laurent Bugnion

Hi,
The "#" is basically a do nothing for those instances where
it really does not make sense to go anywhere. It's also handy when
developing code as an error in the code would cause the link to be
fallowed, which is probably not what we want when trying to track down
errors.

# in a href tells the browser to go to the target named "" (empty
string), just like #targetName tells the browser to go to the target
named targetName. Targets are set on the page with <a name="targetName"></a>

However, when a target cannot be found on the page (and for an empty
string, it's the case), the browser typically jumps to the top of the
page. So the behaviour, in case a JavaScript error occurs is not to do
nothing, but in the contrary it will jump to the top of the page, which
is often something you don't want.

The best way is to use a fallback page in the href.

HTH,
Laurent
 
M

Mani

Laurent,

I want to confirm myself with the below code.

<a name="targetName" href="" ></a>

1.Will the above code take to top of the page or the place where it is
showing in the page?

2. Is including "Javascript: void(0)" in href attribute wrong?

Can you please give me answers for this questions? It would be better
if u explain more in detail.
 
L

Laurent Bugnion

Hi,
Laurent,

I want to confirm myself with the below code.

<a name="targetName" href="" ></a>

1.Will the above code take to top of the page or the place where it is
showing in the page?

No. The "a" tag can be a hyperlink or a target. If you set the "href"
attribute, it's a hyperlink. If you click on a hyperlink, the URL set in
the "href" attribute is loaded in the browser (or at least the browser
attempts to load it. If the "onclick" attribute is set too, and if
JavaScript is enabled on the browser, the "onclick" event handler will
be executed first, and if the code in the "onclick" event handler
returns true, the "href" will be executed after that.

If the "href" attribute is not set, then the "a" tag is interpreted as a
target in the document. Targets are not rendered. They set a named
location on the page. If the URL contains a string after a hash
character '#', the browser will try to find a target with the same name,
and will make it visible to the reader. If the corresponding target
cannot be found, all the browsers I know will jump to the top of the
page (however, I am not sure if that's a specification).
2. Is including "Javascript: void(0)" in href attribute wrong?

Yes. Using the "javascript:" pseudo-protocol is known to cause problems
under certain circumstances.
http://jibbering.com/faq/#FAQ4_24

Can you please give me answers for this questions? It would be better
if u explain more in detail.

HTH,
Laurent
 
M

Mani

Laurent,

I understood. Thanks a lot.

--
Mani



Laurent said:
Hi,


No. The "a" tag can be a hyperlink or a target. If you set the "href"
attribute, it's a hyperlink. If you click on a hyperlink, the URL set in
the "href" attribute is loaded in the browser (or at least the browser
attempts to load it. If the "onclick" attribute is set too, and if
JavaScript is enabled on the browser, the "onclick" event handler will
be executed first, and if the code in the "onclick" event handler
returns true, the "href" will be executed after that.

If the "href" attribute is not set, then the "a" tag is interpreted as a
target in the document. Targets are not rendered. They set a named
location on the page. If the URL contains a string after a hash
character '#', the browser will try to find a target with the same name,
and will make it visible to the reader. If the corresponding target
cannot be found, all the browsers I know will jump to the top of the
page (however, I am not sure if that's a specification).


Yes. Using the "javascript:" pseudo-protocol is known to cause problems
under certain circumstances.
http://jibbering.com/faq/#FAQ4_24



HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top