0

Possible Duplicate:
Small Ajax JavaScript library

I'm programming a library that needs a function to load URLs asynchronously. I'd need the precise same functionality of $.get, except I don't want to have jQuery as a dependency of my library for just one function. What is a self-contained snippet that allows for this?

I've tried several things but most of them are broken somewhere. For example, the most elaborate I could find would get the error Origin <url> is not allowed by Access-Control-Allow-Origin on Chrome.

Community
  • 1
  • 1
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
  • Something like that shown here: http://code.google.com/edu/ajax/tutorials/ajax-tutorial.html (perhaps with a minor change to accept a callback function as a parameter). – nnnnnn Dec 15 '12 at 02:59
  • you trying to get from different domain ? – zb' Dec 15 '12 at 03:05
  • Yes, I am. I'm reading on that link, it says I need to have a local proxy and I have no idea on how I'd have to do that. – MaiaVictor Dec 15 '12 at 03:05

1 Answers1

0

You need to use a basic Ajax call. Look at any tutorial on the XMLHttpRequest object. BUT the problem you have is you are trying to make a cross domain call. That is not possible because of the same origin policy.

In modern day browsers you can make a CORS request, but the server you are requesting has to support it.

Other option is running a local proxy [means you have to have a serverside language application]

The third option is to use a service like yahoo pipes with a jsonp call.

epascarello
  • 204,599
  • 20
  • 195
  • 236