0

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 ?

3
  • Client side or server side? Commented Jun 10, 2014 at 6:28
  • client side (from where data to be sent ) Commented Jun 10, 2014 at 6:36
  • 1
    You might be able to use WebSockets, but in general, you can't connect to arbitrary ports from JS. Commented Jun 10, 2014 at 6:39

2 Answers 2

2

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/

http://en.wikipedia.org/wiki/JSONP

What is JSONP all about?

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

Comments

0

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/

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.