javascript newbie IE + onclick question

D

dean.karres

Hi,

I am working with ajax and have a working tool under netscape, opera
and safari but not IE 6.x (or earlier as far as I can tell).

I have a section of code:

....
<input style="margin-left:20px;margin-bottom:10px;" type="button"
id="PSID_request"
value="Generate Specimen ID"
onclick="getSpecimenID(['PSID_request'], ['PSID']); return true;" />

<div style="margin-left:20px;margin-bottom:20px;background-color:#eee;
font-family:Arial,sans-serif;font-size:1em;padding:2px;text-align:center;
border:1px solid #999;width:9em;min-height:20px;" id="PSID"> </div>
....

The problem: in netscape/firefox and the other working browsers,
everytime I click the button the onclick event is triggered, the
javascript function runs and through the magic of ajax a result is
returned to the following DIV.

In IE, however, If I start the browser from scratch and visit the page
once and click the button once I get a result. If I click the button
again the DIV clears and nothing happens.

I have instrumented the server-side script to log progress as it runs.
In the IE case, on the first button click the function is called and
ajax calls the server-side routine. Afterwards the server-side script
is not run.

I have set the "return true" to false but I'm not sure what else to
try. ideas?
 
J

Joshie Surber

the server-side script is not run.

My first guess (keyword!) would be that you are reusing the same
request object, in which case you should create a new one... or else
you are creating new ones and should try to keep the same one. Turn on
JavaScript error reporting in IE and see what it tells you.
 
D

dean.karres

This was not fun. I am still a javascript and ajax newbie so there are
bits of this I can not explain but here is the short-form:

If you are using the perl CGI::Ajax module, and the "call by URL"
interface, then make sure the remote CGI script that you are calling
sets the "expires" header to "now". IE 6.x seemed to cache the result
of its first call to the CGI. However, on subsequent calls IE would
not force even that result into the result-div.
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top