473,657 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems using AJAX and hyperlinks simultaneously on FF1.5.0.4

Tom
Hi,

I am working on a project where I want to simultaneously launch a link
using my own registered protocol and simultaneously send an AJAX
request to the server.

Now the way I have come up with doing this is by having a normal link
(so that the link still works still if JavaScript is disabled) and an
onClick handler which makes the XMLHTTP request.

The problem is that the XMLHTTP responseText is always null when I do
this. If I execute the same code but from a non-link tag then the
server response comes back just fine (be it the response text or a 404
or whatever).

Something is happening differently when a the XMLHTTP request is sent
from a link. It works ok in I.E. which does not really concern me as I
am turning away from there as my primary browser.

Now I have seen some other people have a similar problem but I have not
seen any solution that I can follow. So am asking outright here using
my own example.

Now I have seen some people that say this is the correct behaviour as,
even though you are not actually navigating away from the page with the
link, a link still implies that this is your intent and so it does
garbage disposal on all the objects. Is this the case or is it a bug?

If it is correct behaviour then I need to work on my solution somewhat
:) Any ideas are welcome. I would rather start from scratch with a more
correct method than do annoying bodges like specifying a new target
window and then having to clean up the blank windows after.

I guess one way is to do the AJAX, process the response and then launch
the app using my registered url protocol. But this would mean waiting
for the server response before launching the app. I would prefer to
launch the app first and then let the server do what it needs to do
when the web page is in the background.

I have tried returnign false from the onClick handler, but it still
follows the link...

Any ideas? Comments much appreciated. Code follows.

Thanks,

Tom....

Test code. This code is just the bare minimum from my project so that
you can see the problem in effect. it may not be 100% gramatically
correct, but it is correct enough do demonstrate my problem. Click on
"test" and the AJAX tries to exacute (just showing you the 404 in the
response). Click on the link and the response is null...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=windows-1250">
<title>Test</title>

<script type="text/javascript"><!--

var http;

function createRequestOb ject() {
var ro;
var browser = navigator.appNa me;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject(" Microsoft.XMLHT TP");
}else{
ro = new XMLHttpRequest( );
}
return ro;
}

function updateserver(sh owId){
http.open('get' , 'backend.php ');
http.onreadysta techange = handleServerRes ponse;
http.send(null) ;
}

function handleServerRes ponse() {
if(http.readySt ate == 4){
var response = http.responseTe xt;
alert(response) ;
}
}

function initialise(){
http = createRequestOb ject();
}

// -->
</script>
</head>
<body onload="initial ise()">
<a href="myprotoco l:c:\test.bin" onClick=updates erver(1)>Link</a>
<br><b onClick=updates erver(1)>Test</b>
</body>
</html>

Jul 22 '06 #1
5 1444
On 22 Jul 2006 02:28:53 -0700, "Tom" <tf******@gmail .comwrote:
>Now I have seen some people that say this is the correct behaviour as,
even though you are not actually navigating away from the page with the
link, a link still implies that this is your intent and so it does
garbage disposal on all the objects. Is this the case or is it a bug?
It's without question a bug.
>If it is correct behaviour then I need to work on my solution somewhat
:) Any ideas are welcome. I would rather start from scratch with a more
correct method than do annoying bodges like specifying a new target
window and then having to clean up the blank windows after.
just target an IFRAME you create, if you're doing so much hacky stuff,
another one really doesn't matter.

Jim.
Jul 22 '06 #2
Tom

Jim Ley wrote:
On 22 Jul 2006 02:28:53 -0700, "Tom" <tf******@gmail .comwrote:
Now I have seen some people that say this is the correct behaviour as,
even though you are not actually navigating away from the page with the
link, a link still implies that this is your intent and so it does
garbage disposal on all the objects. Is this the case or is it a bug?

It's without question a bug.
If it is correct behaviour then I need to work on my solution somewhat
:) Any ideas are welcome. I would rather start from scratch with a more
correct method than do annoying bodges like specifying a new target
window and then having to clean up the blank windows after.

just target an IFRAME you create, if you're doing so much hacky stuff,
another one really doesn't matter.

Jim.
OK, I can do this. I would rather not be hacky, but if its to work
around a bug then sure.

You say I am doing so much hacky stuff. Was it something in my code or
my explanation of what I was trying to do? Could you point out what you
meant?

If I am going about this the wrong way, then I would rather start again
and start a better way.

Cheers,

Tom...

Jul 22 '06 #3
On 22 Jul 2006 10:38:33 -0700, "Tom" <tf******@gmail .comwrote:
>You say I am doing so much hacky stuff. Was it something in my code or
my explanation of what I was trying to do? Could you point out what you
meant?
Sure, a registered protocol handler, seperate reporting with xmlhttp
request etc. - none of it is stuff that is normal web stuff, and
you'll need to test carefully with any client you wish to use.
>If I am going about this the wrong way, then I would rather start again
and start a better way.
Well we have no idea what you want to achieve :) I would've thought
having the 3rd party tool report it's being used - rather than the XHR
which only indicates the attempt would make some sense for example.

Jim.
Jul 22 '06 #4
Tom

Jim Ley wrote:
On 22 Jul 2006 10:38:33 -0700, "Tom" <tf******@gmail .comwrote:
You say I am doing so much hacky stuff. Was it something in my code or
my explanation of what I was trying to do? Could you point out what you
meant?

Sure, a registered protocol handler, seperate reporting with xmlhttp
request etc. - none of it is stuff that is normal web stuff, and
you'll need to test carefully with any client you wish to use.
If I am going about this the wrong way, then I would rather start again
and start a better way.

Well we have no idea what you want to achieve :) I would've thought
having the 3rd party tool report it's being used - rather than the XHR
which only indicates the attempt would make some sense for example.

Jim.
Fair points :) Thanks.

What I am trying to achieve: I am just trying to make a web front end
for playing my tv shows etc(Don't have access to any of them on normal
TV in the country I live in). I want to be able to launch a show (which
I am doing with mplayer) and update the server so it knows which shows
could have been watched.

Partially re-inventing the wheel, yes, but mostly just a self-exercise
for me in JS and stuff like that. I have a registered protocol as just
having a hyperlink to a media file always tries to download the file
locally and ask what to do with it etc etc( I realise this means
modifying the client which annoys me intensely, but I was a bit stuck
there...). Reporting back with XHR cos.. well, I would like to get more
to grips with it :)

I guess I will just continue along with my bodges for this little
project and go ahead and use the iframe (which works just great, ta!).
I'll just keep in mind that this is one of those bodgy projects :)

Cheers,

Tom...

Jul 23 '06 #5
On 23 Jul 2006 00:48:27 -0700, "Tom" <tf******@gmail .comwrote:
>I guess I will just continue along with my bodges for this little
project and go ahead and use the iframe (which works just great, ta!).
I'll just keep in mind that this is one of those bodgy projects :)
There's nothing wrong with such projects, it's a great way to learn
stuf, remember hacky is not a perjorative, it can be a hacky project
and still be good, and still be the best way of doing what you're
doing.

Jim.
Jul 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1395
by: black | last post by:
Do you know for any good URL, portal, forum, newsgroup, yahoo (etc.) group, etc., to find more about AJAX? Thanks
2
2049
by: christopher.secord | last post by:
I would like have a little "loading..." tab not unlike the one that gmail uses and I would like to display that tab while an ajax call is made. The javascript to display the tab works. The javascript to hide the tab works. But when I put the two together inside the function that calls the ajax service, they don't work. What seems to happen is that calls to change DOM object properties are queued up, and then all executed...
6
2594
by: Bart van Deenen | last post by:
Hi All I'm happily creating an Ajaxified web-app. I use Prototype for encapsulating xml http requests, with method "post". On the backend, I use PHP, and the replies are eval'd by Javascript. I do not use XML for data encapsulation. The only thing that is off nominal is that my Firefox 1.07 (Mac OS-X) and 1.06 (Linux) have "Waiting for ..." continuously in the status bar. I know from server debugging and packet sniffing that there is...
16
2524
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client uses IE to talk with a server. The user on the client (IE) sees an ASP net page containing a TextBox. He can write some text in this text box and push a submit button.
0
1727
by: minnie | last post by:
Recommend an AJAX IDE Simultaneously Support AJAX applications development in Java and .NET. The programming language including Java, C# and VB. AJAX UI Library, totally visual design AJAX pattern. More powerful Coding aoto-complement. so more information... May free download you should check http://www.joyistar.com
2
3833
by: dmagliola | last post by:
Hello all, I'm experiencing a problem with ASP.Net for which I can't find a reasonable explanation, or any information. I'm currently developing an application that, through AJAX, asks the server for updated information to show, and can also send information to the server. To do this, I have an XMLHttpRequest that queries an Asynchronous HTTP
5
8801
LAD
by: LAD | last post by:
Using Access 2003 on Windows 2000. My Skill Level: Med Low (Some VBA, okay with Access) Form: Single View - based on Query of single Table to sort by field. Application: Dealers email 'contract packages' that include as attachments: a contract (PDF or TIF), a pricing tool (Excel), a companion document (Word). Clerks detach these files into a shared drive file on our intranet. I'm building an 'contract package management' application...
11
2595
by: burtonfigg | last post by:
I've read this article: http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/ullman-ajax.html And from reading it thought it'd be interesting to try a bit of Ajax on my site. What I'd really like to do is to set up a little ajax widget on my site, so that if people want to view more of the ecard thumbnails, they can click little next/prev icons to view the next / previous 8 thumbnail ecard images. I suppose in a way I want...
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.