JQuery load() in IE8 POST&GET not working?

2019-06-14 05:02发布

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?

3条回答
三岁会撩人
2楼-- · 2019-06-14 05:23

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!

查看更多
叼着烟拽天下
3楼-- · 2019-06-14 05:32

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.

查看更多
forever°为你锁心
4楼-- · 2019-06-14 05:46

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);

}
查看更多
登录 后发表回答