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.

3
  • Something like that shown here: code.google.com/edu/ajax/tutorials/ajax-tutorial.html (perhaps with a minor change to accept a callback function as a parameter). Commented Dec 15, 2012 at 2:59
  • you trying to get from different domain ? Commented Dec 15, 2012 at 3: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. Commented Dec 15, 2012 at 3:05

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.