473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Ajax Script - works in Firefox, not in IE6

I'm testing an ajax page - this works fine in Firefox:
http://jimpix.co.uk/clients/a/ecards/defaultx.asp

Click on any of the links on the right under the 'occassions' or 'others' headings, in Firefox, and thumbnails appear based on what you clicked on.

Do the same in IE6, and it returns an error:

Line: 71
Char: 9
Error: Unknown runtime error


This relates to this line:

Expand|Select|Wrap|Line Numbers
  1. <p class="ctr"><span id="my_photo_id_label"></span></p>
The error happens as soon as the page is loaded, before I even click a link.

This is the javascript on the page:

Expand|Select|Wrap|Line Numbers
  1. function addLoadEvent(func) {
  2.     var oldonload = window.onload;
  3.     if (typeof window.onload != 'function') {
  4.         window.onload = func;
  5.     } else {
  6.         window.onload = function() {
  7.             if (oldonload) {
  8.                 oldonload();
  9.             }
  10.             func();
  11.         }
  12.     }
  13. }
  14.  
  15. function GetXmlHttpObject() {
  16.   var xmlhttp;
  17.   if (window.XMLHttpRequest) { // Mozilla, Safari, Opera...
  18.     xmlhttp = new XMLHttpRequest();
  19.     //if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
  20.   } else if (window.ActiveXObject) { // IE
  21.       try {
  22.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  23.       } catch (e) {
  24.           try {
  25.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  26.           } catch (e) {}
  27.       }
  28.   }
  29.   if (!xmlhttp) {
  30.     alert('Cannot create an XMLHTTP instance');
  31.     return false;
  32.   }
  33.   return xmlhttp;
  34. }
  35.  
  36. var ec = GetXmlHttpObject();
  37.  
  38. function sendMyPhotoRequest(id) {
  39.     ec.open('get', '../ajax/ajax-ec.asp?id=' + encodeURIComponent(id));
  40.     ec.onreadystatechange = handleMyPhotoResponse;
  41.     ec.send(null);
  42. }
  43.  
  44. function handleMyPhotoResponse() {
  45.     // If everything is okay:
  46.     if(ec.readyState == 4){
  47.         // Assign the returned value to the document object.
  48.         document.getElementById('my_photo_id_label').innerHTML = ec.responseText;
  49.     }
  50. }
  51.  
  52. addLoadEvent(function() {
  53.     sendMyPhotoRequest(44);
  54. })
The plan was to click a hyperlink on the right, and then send a variable to the 'ajax-ec.asp' page, via this syntax:

Expand|Select|Wrap|Line Numbers
  1. <li><a href= "#pop" onclick="sendMyPhotoRequest(45);">Various</a></li>
Not sure why it would work for Firefox, but not IE6.

I tested on another page:
http://jimpix.co.uk/clients/a/ecards/default-photo.asp

And this works in IE6, even though the Javascript is v. similar.

But instead of passing the variable as a number as above, the hyperlink is as follows:

Expand|Select|Wrap|Line Numbers
  1. <a title="" href="#pc" onclick="sendPhotoRequest(next_photo());">Next</a>
And the function initialising the page is:

Expand|Select|Wrap|Line Numbers
  1. addLoadEvent(function() {
  2.     sendPhotoRequest(MyPhotoVar);
  3. })
Where MyPhotoVar is initialised as:

Expand|Select|Wrap|Line Numbers
  1. var MyPhotoVar = 0;
Is that the problem - that I can't send numbers via the functions, but need to use a variable instead?

I'm sorry for:

1. Going on for so long
2. Not knowing what I'm doing
3. Talking a load of rubbish

Thanks
Sep 26 '08 #1
2 1626
Fixed it. Sorry to waste anyones time.
Sep 27 '08 #2
Markus
6,050 Expert 4TB
Fixed it. Sorry to waste anyones time.
Care to post how you solved this problem? It may help others.

Cheers.
Sep 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Danny | last post by:
Hi all, I am having some odd problems with AJAX on Firefox (1.5). When I use GET as the request method everything works ok, but when I do a POST the remote function doesn't get the parameters I...
5
by: Danny R | last post by:
I have the following javascript which works in either IE or Firefox but not on both. When I set the code to http_request.open('POST', url, true) - Works in IE only http_request.open('GET',...
4
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole...
5
by: Ruso | last post by:
I am using ASP to make an application. What I want right now - is to make the self updating list of the users online - based on thier cookies. In my opinion all seems to be writen well with it's...
3
by: noballack | last post by:
I've got a problem, I'm working with Ajax in a web with a form with a list of checkbox added to the form via an Ajax.Updater method. These added checkboxs are not been sended by the form if I use...
2
by: germ | last post by:
doing a simple page webmethod call an a page via PageMethods works fine in ie7 & opera9 the same call on firefox ( and I assume netscape ) generates the following error : Error: " nsresult:...
8
by: henryrhenryr | last post by:
I'm trying to log all links clicked. I'm just working this out so there may be some astoundingly bad methods. Please point out! It all works nicely though if I use mouseover events as the...
3
rizwan6feb
by: rizwan6feb | last post by:
Hi experts! Recently i was working on "Form Validation Using Ajax". My form validation was creating problem, when a user changes focus too quickly. I had a post related to this, but was unable to...
7
by: mike57 | last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.