Jump to content

Internet Explorer Woes


interpim

Recommended Posts

OK, i have sat through, baby stepping my way through learning Ajax.

 

Well, I thought i had a fairly decent working start on something after about 10 hours of playing around and coding/recoding things.

 

Then, i checked it in Internet Explorer, and well, it doesn't work :(

 

So can anyone tell me why it isn't working?

here is the site

http://interpim.com/vn_emblem

 

and here is my code

 

<head>
<SCRIPT Language="JavaScript">
var z = 11;
var x = 1;
var y = 1;
var sh = 1;
var col = 1;
function getHTTPObject() {
    var xmlhttp;
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

var http = getHTTPObject();

function ajaxbackFunction(){
   z=z-1 ;
   if(z <= 0){
   z = 278;
   }
   document.form.pic_num.value=z;
   http.open('GET', 'ajax.php?pic='+z, true);
   http.send(z);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('somediv').innerHTML = http.responseText; // this will put the returned code from ajax.php into a div with id "somediv"


      }
   }
}
function loadImage(){
document.getElementById('somediv').innerHTML = "<img src='order/012.gif'>";
document.getElementById('shape').innerHTML = "<img src='order/shape1.gif'>";
document.getElementById('base').innerHTML = "<img src='images/base1.gif'>";
document.getElementById('shape').innerHTML = "<img src='order/sh1col1.gif'>";
}

function ajaxFunction(){
   z=z+1 ;
   if(z >= 279){
   z = 1;
   }
   document.form.pic_num.value=z;
   http.open('GET', 'ajax.php?pic='+z, true);
   http.send(z);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('somediv').innerHTML = http.responseText; // this will put the returned code from ajax.php into a div with id "somediv"
      }
   }
}

function shape_fwd(){
   x = x + 1;
   if(x >= 6){
   x = 1;
   }
   document.shape_form.shape_num.value=x;
   http.open('GET', 'shape.php?pic='+x, true);
   http.send(x);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('shape').innerHTML = http.responseText; 
      }
   }
}
function shape_back(){
   x=x-1 ;
   if(x <= 0){
   x = 5;
   }
   document.shape_form.shape_num.value=x;
   http.open('GET', 'shape.php?pic='+x, true);
   http.send(x);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('shape').innerHTML = http.responseText; 
      }
   }
}
function base_fwd(){
   y = y + 1;
   if(y >= 4){
   y = 1;
   }
   document.base_form.base_num.value=y;
   http.open('GET', 'base.php?pic='+y, true);
   http.send(y);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('base').innerHTML = http.responseText; 
      }
   }
}
function base_back(){
   y=y-1 ;
   if(y <= 0){
   y = 3;
   }
   document.base_form.base_num.value=y;
   http.open('GET', 'base.php?pic='+y, true);
   http.send(y);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('base').innerHTML = http.responseText; 
      }
   }
}
function pat_color_fwd(){
   col = col + 1;
   if(col >= 4){
   col = 1;
   }
   document.pat_color_form.pat_color_num.value=col;
   http.open('GET', 'pattern.php?pic='+sh +'&col='+col, true);
   http.send(sh,col);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('pattern').innerHTML = http.responseText; 
      }
   }
}
function pat_color_back(){
   col=col-1 ;
   if(col <= 0){
   col = 3;
   }
   document.pat_color_form.pat_color_num.value=col;
   http.open('GET', 'pattern.php?pic='+sh +'&col='+col, true);
   http.send(sh,col);
   http.onreadystatechange=function(){
      if(http.readyState==4){
        document.getElementById('pattern').innerHTML = http.responseText; 
      }
   }
}
</script>
<style type="text/css" title="currentStyle" media="screen">
	@import "style.css";
		</style>

</head>
<BODY onLoad="javascript: loadImage()">
<div id='somediv'>
</div>

<div id='bg'>
<img src='bg.gif'>
</div>

<div id='base_click'>
<form name='base_form'>
<input type="button" name="base_down" value="<<" onclick="base_back()">
<input type="text" name="base_num" size='5'>
<input type="button" name="base_up" value=">>" onclick="base_fwd()">
</form>
</div>

<div id='shape_click'>
<form name='shape_form'>
<input type="button" name="shape_down" value="<<" onclick="shape_back()">
<input type="text" name="shape_num" size='5'>
<input type="button" name="shape_up" value=">>" onclick="shape_fwd()">
</form>
</div>

<div id='pattern_click'>
<form name='pattern_form'>
<input type="button" name="pattern_down" value="<<" onclick="pattern_back()">
<input type="text" name="pattern_num" size='5'>
<input type="button" name="pattern_up" value=">>" onclick="pattern_fwd()">
</form>
</div>
<div id='pat_color_click'>
<form name='pat_color_form'>
<input type="button" name="pat_color_down" value="<<" onclick="pat_color_back()">
<input type="text" name="pat_color_num" size='5'>
<input type="button" name="pat_color_up" value=">>" onclick="pat_color_fwd()">
</form>
</div>
<div id='emblem_click'
<form name='form'>
<input type="button" name="backbutton" value="<<" onclick="ajaxbackFunction()">
<input type="text" name="pic_num" size='5'>
<input type="button" name="thisbutton" value=">>" onclick="ajaxFunction()">
</form> 
</div>

<div id='overlay'>
<img src='images/overlay.png'>
</div>
<div id='base'>
</div>
<div id='pattern'>
</div>
<div id='shape'>
</div>

Link to comment
Share on other sites

Hi, I'm really new to AJAX to, but I think the problem is your getHTTPbject function.

This is from an AJAX tutorial I'm reading:

In order to make an HTTP request to the server using JavaScript, you need an instance of a class that provides this functionality. Such a class was originally introduced in Internet Explorer as an ActiveX object, called XMLHTTP. Then Mozilla, Safari and other browsers followed, implementing an XMLHttpRequest class that supports the methods and properties of Microsoft's original ActiveX object.

I dont think the way you create the object works in IE.

try this (from the tutorial again):

var httpRequest;

 

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...

            httpRequest = new XMLHttpRequest();

            if (httpRequest.overrideMimeType) {

                httpRequest.overrideMimeType('text/xml');

                // See note below about this line

            }

        }

        else if (window.ActiveXObject) { // IE

            try {

                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");

            }

            catch (e) {

                try {

                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

                }

                catch (e) {}

            }

        }

 

        if (!httpRequest) {

            alert('Giving up :( Cannot create an XMLHTTP instance');

            return false;

        }

 

If your interested here is a link to the tutorial:

https://developer.mozilla.org/en/AJAX/Getting_Started

 

If that doesn't work could you say what the error is, not just that it doesn't work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.