I need to send some data ( say name, place, birth of year ) to a different machine ( say IP:70.80.203.55 port:5555) through javascript. I am new to javascript. Can u please tell me how can I do it ?
-
Client side or server side? – Felix Kling Jun 10 '14 at 06:28
-
client side (from where data to be sent ) – prashantas Jun 10 '14 at 06:36
-
1You *might* be able to use [WebSockets](http://www.html5rocks.com/en/tutorials/websockets/basics/), but in general, you can't connect to arbitrary ports from JS. – Felix Kling Jun 10 '14 at 06:39
2 Answers
You can use jsonP for sending cross site data from javaScript. For more details on jsonP you can refer following links
http://learn.jquery.com/ajax/working-with-jsonp/

- 1
- 1

- 1,756
- 1
- 12
- 18
so, there are a few ways of doing that. i would recommend CORS: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
using apache webserver on the external machine ( say IP:70.80.203.55 port:5555) you need to edit a .htaccess-file to allow external sources to send requests to the machine following the rules you've defined. the ajax request on your machine just hast to follow these rules as well, so it succeeds. should also be crossbrowser compatible: caniuse.com/#search=CORS
For Detailed Information on UsingCors with JavaScript: http://remysharp.com/2011/04/21/getting-cors-working/

- 73
- 1
- 10