tags:

views:

44

answers:

3

Hello,

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

+2  A: 

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.

meder
A: 

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.

Collin Allen
A: 

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.

Alexander Sagen