0

I'm wondering if anyone has come across any libraries in javascript that can emulate something like php's cURL?

2
  • At least for in-browser JavaScript, cross-domain rules will make that of limited use. And is it much different from an XmlHttpRequest anyway? Commented Sep 27, 2010 at 3:14
  • Why yes... jQuery can do pretty much everything cURL can. Commented Sep 27, 2010 at 3:15

3 Answers 3

2

XMLHttpRequest can fetch resources on the same domain/server. If you need something externally just use XHR/Ajax to a server-side page that fetches the external data and outputs it so your XHR can grab it.

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

Comments

1

Not possible as the browser sandbox doesn't allow you to make TCP sockets directly. You're limited to the options given by XmlHTttpRequest. You'd need a server-side proxy script to do what you want. Or use flash/java which gives you more options regarding connectivity. Still restricted to the same domain I believe though.

1 Comment

This is the only explanation I have seen of why JavaScript doesn't use cURL. Thanks.
0

Client-side JavaScript running in a browser only has access to XMLHttpRequest, which are just HTTP requests. cURL does much more than just HTTP, with a whole lot more control, including cross-domain requests. The things JavaScript can do are really quite limited.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.