开发者

.NET Dynamic XML reads fine in all browsers except IE

开发者 https://www.devze.com 2023-01-18 12:38 出处:网络
Using AJAX to pull data from a dynamically generated XML using .NET. Using simple jQuery Ajax: $.ajax({

Using AJAX to pull data from a dynamically generated XML using .NET. Using simple jQuery Ajax:

$.ajax({
type: "GET",
url: "/test/dynamic.aspx",
success: function(xml) {

    var itemTitleSrc = $(xml).find('ItemName').text();
    alert(itemTitleSrc);

}

});

In Firefox, Chrome, Safari, the alert brings back all of the strings associated with the node i am telling it to find. In IE, the alert box comes in blank. If I switch out the dynamic url and change it to a static XML and search for a node, both browsers come back with the same info.

My question is, could there be some kind of permissions set to the dynamic XML that IE is following and refusing to bring back the desired information.

On another quick note, if I create an alert开发者_Python百科 for the data itself, like so:

alert(xml);

Both browsers, return the same data. It only seems that IE refuses to bring info either from a dynamically created XML and/or only when I search for a particular node.

Anyone with ideas?


First of all try to repeat the test with additional parameter cache: false of jQuery.ajax.

It would be also interesting to change success function to function(xml, textStatus, xhr) and display xhr.responseText with alert(xhr.responseText). The parameter dataType:"xml" can be also helpful depending whether you set content-type in the server response.

UPDATED: If you do receive the xml data in the IE and can only not load XML data, then you should follow the recommendation from the jQuery Documentation. You should test whether the current browser is IE. For IE you should load the data as text: dataType: "text" and then inside of success handler convert the xml text to ActiveXObject("Microsoft.XMLDOM") object.

0

精彩评论

暂无评论...
验证码 换一张
取 消