I know jquery/ajax in IE is a common problem. There is a lot of great advice here on stack overflow but none of it has worked for me yet. The following code works just fine in firefox, but does not in IE:
$.ajaxSetup({ cache: false })
$.ajax({
url: 'FunDataService.asmx/' + funDataMethod,
type: 'POST', dataType: 'html', cache: false, timeout: 3000,
error: function() {alert('Error updating fun information. Refresh the page and try again.');},
success: function(htmlFunInfo) {
alert($(htmlFunInfo).text());
$("#fundiv").html($(htmlFunInfo).text())},
data: parameters
});
You can see my anti-caching attempts; I've also added random values to the URL. I've also tried adding various content headers on the web service:
' Context.Response.ContentType = "text/html; charset=utf-8"
' Context.Response.ContentType = "text/html"
Context.Response.ContentType = "text/plain"
The alert command is for debugging of course. In FF, $(htmlFunInfo).text()
is the div tags sent down from the server that I wish to insert. In IE, it is empty string.
Does anyone know how to get access to this string value in IE? Thanks!
Edit The response from the server is like:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="tempuri.org/">
<div>stuff</div>
<div>more stuff</div>
</string>
Increasingly I think that is what's wrong, that I need to avoid the wrapping around the divs.
Edit 2 That's it! In my server code, I replaced:
Return RemarkHtml
with
Context.Response.Write(RemarkHtml)
This avoided the tags surrounding the divs, and now I'm good. Still, I think it's a big problem that in IE, you just can't get to the contents of tags using .text().
Thanks guys!