Ben Reichelt's Weblog

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Cross Domain XmlHttpRequests (Ajax)

[Advertisement]

Comments

Brendan Tompkins wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-11-2005 8:52 AM
Ben,

This stuff is the future. A little remote scripting sprinkled on top, and this could really zing..

Just curious, though. Why the (Ajax) in the title?
Ben Reichelt wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-11-2005 9:17 AM
Brendan, I just wanted to make sure that people who have PubSub, Feedster, etc. feeds that are watching for the word "ajax" saw this post. And it is "ajax", we asynchronously get the rss feed, and then we use the DOM and dhtml to display the resulting xml in the browser.
Brendan Tompkins wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-11-2005 10:05 AM
I see... It looks like you were saying that "Cross-Domain XmlHttpRequests" = "Ajax" I'm still a bit confused myself, to tell you the truth... ;)
John Papa wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-11-2005 10:06 AM
Great timing, Ben. I just had a question today from a buddy of mine who is doing this but the XML coming in throws this exception when the XmlDocument.Load method is invoked:

'', hexadecimal value 0x12, is an invalid character. Line 1, position 6118.

Any idea on a recommended practice for stripping the character out or making it readable?
Ben Reichelt wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-11-2005 10:16 AM
Brendan - I understand the confusion, I didn't consider that when I made the title :) I simply put the word "Ajax" in there as sort of a meta keyword so that it would hit on google searches and whatnot. I generally don't care for the "ajax" term, but I realize that many people do.

John - I usually run into that problem when I'm making a request to a page that I expect to return xml, but then an asp.net exception gets thrown so the result is actually html content which makes the XmlDocument throw an error while its parsing.
John Papa wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-11-2005 10:23 AM
Ben, my friend is writing an RSS feed reader for SharePoint. The feed comes in most of the time as standard XML. But once in a while he gets the exception. I'm not sure what to tell him other than that he could read the entire string and strip out those characters (or write an event handler for it).

Oh well.
Eric Wise wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-11-2005 10:49 AM
Nice Ben. =)

Though you totally killed the post I was going to do on this in a week or two.

Great minds think alike...
Joshua Flanagan wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-12-2005 11:39 AM
HttpHandlers are also great for this type of thing.

Since they so thoughtfully included support for custom HttpHandlers in .NET (near the top of my list of favorite features), we no longer have to treat everything like a "page". I use the Page class when I want to render a UI. I use custom HttpHandlers when I just want to perform some service at an HTTP endpoint.

I'm sure the perf gain is minimal, but its nice from a design/code clarity perspective.
Ben Reichelt wrote re: Cross Domain XmlHttpRequests (Ajax)
on 04-12-2005 11:46 AM
Joshua, I just started experimenting with using a custom handler, it is pretty cool that you can interrupt the request like that. I'm using it to stream files to the user.

-ben
Ben Reichelt's Weblog wrote Ajax POST request
on 04-22-2005 6:20 AM
As kind of a followup to my post about how to redirect XmlHttpRequests outside your domain, which was...
Robin Curry wrote AJAX and ASP.NET Resources
on 04-22-2005 8:07 AM
Robin Curry wrote AJAX and ASP.NET Resources
on 04-25-2005 11:53 AM
Robin Curry wrote AJAX and ASP.NET Resources
on 04-25-2005 11:54 AM
Jacek wrote re: Cross Domain XmlHttpRequests (Ajax)
on 08-31-2005 6:08 AM
Ben,

Great post!
But just so you know, post-SP2 IE <b>does</b> allow cross-domain use of Ajax provided that you add the site to your "Trusted Sites".
Adnan Siddiqi wrote Customized Ajax based Contact Form for Blogger.com or any other side
on 01-10-2006 6:01 AM
In my last post,i mentioined about drawback of AJAX to use it across domain,you get Permission Denied...
Adnan Siddiqi wrote Customized Ajax based Contact Form for Blogger.com or any other side
on 01-15-2006 4:26 AM
In my last post,i mentioined about drawback of AJAX to use it across domain,you get Permission Denied...
ray cheng wrote re: Cross Domain XmlHttpRequests (Ajax)
on 02-27-2006 8:55 PM
my only worry about doing this way is your server gets the content of the external domain instead of the client. if the client gets bad content, my server is still clean and safe. i won't want to put my server on risk.

ray