0

Heres my Situation.

Im trying to relaod a div in a page with load().

I first tryed with a GET. Worked fine with Firefox but not IE8.

After a bit of reading, i found out that i had to POST my PARAM so i went on and did a POST.

The result is just the same. It wont work in IE8. Here is the line im using for the POST.

$(\'#test_1\').load( \'../ajax_http.php\',{variable2:xload})

Firebug, (firefox debug add-on), Is seeing the action as a POST and see the PARAM value So its going trough as a POST but still not working in IE8.

This is the actual line im using:

echo '<div id="test_1" class="test_1" OnClick="$(\'#test_1\').load( \'../ajax_http.php\',{variable2:xload});">';

Any ideas?

MadeInDreams
  • 1,991
  • 5
  • 33
  • 64

3 Answers3

1

So if IE8 wont let me GET my data I will get it my self! i came up with

function req_product(user,action,product) {
var data = getXMLHttpRequest();

data.onreadystatechange = function() {
    if (data.readyState == 4 && (data.status == 200 || data.status == 0)) {


        document.getElementById("product_box").innerHTML=data.responseText;

    }

};

var sVar1 = encodeURIComponent(product);
var sVar2 = encodeURIComponent(user);
var sVar3 = encodeURIComponent(action);


data.open("GET", "ajax_http.php?variable1=" + sVar1 + "&variable2=" + sVar2 + "&variable3= " + sVar1, true);
xhr.send(null);

}

It's working fine with IE8, Firefox 3.5.1, Netscape9.0 as well as Opera 9.5 So this is where i will start from!

MadeInDreams
  • 1,991
  • 5
  • 33
  • 64
1

I got this working with an extra function (there was also a litte typo in the example):

function getXMLHttpRequest() 
            {
                if (window.XMLHttpRequest) {
                    return new window.XMLHttpRequest;
                }
                else {
                    try {
                        return new ActiveXObject("MSXML2.XMLHTTP.3.0");
                    }
                    catch(ex) {
                        return null;
                    }
                }
            }

function req_product(user,action,product)
{
        var data = getXMLHttpRequest();

        data.onreadystatechange = function() {
            if (data.readyState == 4 && (data.status == 200 || data.status == 0)) 
            {
                document.getElementById("product_box").innerHTML=data.responseText;
            }

        };

        var sVar1 = encodeURIComponent(product);
        var sVar2 = encodeURIComponent(user);
        var sVar3 = encodeURIComponent(action);

        data.open("GET", "ajax_http.php?variable1=" + sVar1 + "&variable2=" + sVar2 + "&variable3= " +sVar1, true);
        data.send(null);

}
Cake
  • 11
  • 1
0

First of all, I'll assume that's a snippet of PHP code. Did you try setting the onclick using the

$("#test_1").click(function(){$('#test_1').load( '../ajax_http.php',{variable2:xload});});

method? It could be an encoding issue. Check the debugger.

zacharyliu
  • 25,578
  • 4
  • 21
  • 15
  • Yes it is output with php as UTF-8. i tried your line. Im no sure where i should use it, im really new to JQuery. So i tried to place your line into the OnClick='' event inside the
    tag. where my line was and it wasnt working at all. Not even in Firefox. i also tryed the line inside the
    – MadeInDreams Jul 23 '09 at 23:46
  • Ok got your line to work and i get the same result. Works in Firefox not IE. – MadeInDreams Jul 23 '09 at 23:56
  • Firebug still says that everything is fine hes getting the post – MadeInDreams Jul 24 '09 at 00:10
  • I have tryed this line: $(\'#test_1\').load( \'../ajax_http.php\',(\'variable2\',xload) Firebug is showing me this request as a GET mypage.php&xload All i need now i guess would be to put a variable2= in font of it and repeat? do they work as array?? – MadeInDreams Jul 24 '09 at 02:01
  • So The funny thing about this is that i managed to get Something to display in my page. I could actualy reach the page with $(\'#test_1\').load( \'../ajax_http.php\',(variable2,xload) variable2 and xload ar both string like xload ="variable2=xload"; variable2 = "a string that isnt showing in the GET param line!?" Firefox is getting the request GET mypage.php?variable2=xload and give me what i want. However IE8 still wont. Now its coming back to how to turn this one into a POST ?? – MadeInDreams Jul 24 '09 at 02:29
  • $(\'#test_1\').load( \'../ajax_http.php\',(\'variable2\',xload)); Actualy display stuff. My php warning becuse variable2 isnt set. – MadeInDreams Jul 24 '09 at 02:34