views:

141

answers:

2

Hi. I tried to open a post time ago about this problem (here), thinking i was wrong making the code. Now more or less i've understood that some version of Jquery with my code doesnt work on IE7. What's Happening? I also tried to open a post on JQuery official forum (link) but no one reply. Anyway, in my old website i used to work with jquery-1.3.2.min.js , and i didnt problems. Now, i need to use the .delegate() function, so I include the jquery-1.4.2.min.js library.

Above you can see the usual code I used in my old application :

// html page
<a href="#" onClick="pmNew('1');return false">prova</a>    

// javascript page
function pmNew(mexid) {
    var time = new Date;
    $.ajax({
        type: 'POST',
        url: './folder/ajax.php',
        data: 'mexid='+escape(mexid)+'&id=pmnew',
        success: function(msg) {
            alert(msg);
        }
    });
    return false;
}

// asynchf.php
if($_POST['id']=="pmnew") {
    echo "please, i will just print this";
}

With some suggestions by some users of this website, i edited these functions :

// html page
<a href="#" onClick="pmNew('1');return false">prova</a>    

// javascript page
function pmNew(mexid) {
    var time = new Date;
    $.ajax({
        type: 'POST',
        cache: false,
        url: './folder/ajax.php' + '?dummy=' + time.getTime(),
        data: 'mexid='+escape(mexid)+'&id=pmnew',
        success: function(msg) {
            alert(msg);
        }
    });
    return false;
}

// asynchf.php
if($_POST['id']=="pmnew") {
    echo "please, i will just print this";
}

But it STILL DOESNT WORK on IE7. Firefox, Chrome, it rocks. It works on IE7 only if i load the page, i try (and i get the error message), i reload (F5) and i retry. Or, as i said before, i change the version of Jquery :)

I loaded a testpage on a real server (so you can check yourself this problem) : click here

I hope someone can help me with this big trouble.

Cheers

A: 

Can you add this argument to your .Ajax options:

error:function(xhr, status, errorThrown) {
            alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
        }, 

and reply with the message ?

Russ C
tried. Nothing!
markzzz
Updated answer.
Russ C
i tried. It doenst print. It seems that the ajax call doesnt exit to the server o_O
markzzz
That's a shame; I was hoping it might be related to this: http://forum.jquery.com/topic/fix-jquery-ajax-errors-in-ie
Russ C
uhm...but why? It works fine on jquery-1.3.2.min.js ... hehe! i loaded the page online, check it out the link...
markzzz
It was a hunch more than anything. Unfortunately, I don't have an IE7 box here, but Fiddler should work, I suspect you'll need to configure it to be your Proxy, for it to capture packets. This page has some details that might help: http://www.fiddler2.com/fiddler/help/hookup.asp
Russ C
One more thought, what happens if you remove the period at the start of the path?
Russ C
If i remove the period its the same. In fact it doesnt help...! About Fiddler, i have some problems with localhost. So i've uploaded a page on real server. It grabs the traffik now, but it grabs nothing when i call that function. Really, i dunno what's happened. I've thought to a virus on my pc, but a friend of mine get the same error with other pc and the same browser. A very mistery for me...
markzzz
+3  A: 

The reason behind this bug is when you are using relative URLs on IE7, it actually adds your base url (or wherever your page is loaded from e.g. if you place a relative url on your home page your relative URL would actually be http://gabbatracklistworld.com/http://gabbatracklistworld.com/folder/ajax.php)

I just came across your question here on SO while searching for a solution on some same problem I had myself a few minutes ago. There's actually an article from microsoft's blog that explains how IE7 handle relative urls (which is funny because it just shows that they are proud of how their stupid browser works) Seeing that you have no answer yet, I'd put my solution here for future reference and other devs too.

What I did is use substring() to strip the instances of my base url forcing the ajax request to use the actual relative URL.

lock
Yeah, probably that's the problem. But why this work with jquery-1.3.2.min.js?
markzzz