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

▼魔方 西西 提交于 2019-12-23 04:40:41

问题


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?


回答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!




回答2:


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

}



回答3:


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.



来源:https://stackoverflow.com/questions/1174945/jquery-load-in-ie8-postget-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!