views:

22

answers:

1

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 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?

A: 

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.

Oleg
Thanks for the reply. I tried setting the cache to false, however that did not do anything.
Jim
Also, rewrote the function and ran the alert, got the markup of the xml in both FF and IE as I did before when running alert(xml). Oddly enough though, no luck.
Jim
@Jim: I updated my answer. I hope if you follow the recommendation your code will work.
Oleg
That did the trick. I had to use jquery browser detection since FF did not want to run my ajax as an xml dataType... So I wrapped the entire AJAX call inside of a $.browser.msie conditional, and ran the original script in the !$.browser.msie conditional... Works as expected. Thanks for the forward.
Jim