Finn Luca Frotscher
Finn Luca Frotscher

Reputation: 395

JavaScript send&receive data cross server

I taught myself programming so my knowledge is very fragmented and now I have encountered a fragment I know nothing about. Sending and receiving Date. In addition I want to do it across domains. I know about the security policies that prohibit this but have read about some solutions. I still can't make sense of it in relation to my challenge.

What I want to do:

I want to build a plugin that sends data to my server when a function is called. The function is bound to an event listener. this plugin contains of a little html-form and some js in the back. i want to send json or simular. my questions:

I) how do I send data to an other server?

II) how do I receive this data? I know about parsing and dom but all I did so far is handle requested data. now this data is posted to my server-app without me knowing beforehand. the data is used to update a DB. the backend is coded in JS or python. I would prefer JS for compatability reasons.

III) how can I test the cross server connection on my local machine? especially without an active internet-connection?

I don't expect a complete guide or the code i need. just the resources and where to get the knowledge-chunks I need to build this.

Thanks a bunch in advance!

Upvotes: 1

Views: 127

Answers (1)

Alex Lau
Alex Lau

Reputation: 1697

I) how do i send data to an other server?

You may use AJAX (or jQuery.ajax a more convenient way)

II) how do i receive this data? i know about parsing and dom but all i did so far is handel requested data. now this data is posted to my server-app without me knowing beforehand. the data is used to update a DB. the backend is coded in JS or python. i would prefer JS for compatability reasons.

As long as you send some data via AJAX, the browser makes a HTTP call and you could receive the data from server-side. Both JS or python would compatible with your client-side javascript and seldom do there have compatibility issue.

III) how can i test the cross server connection on my local maschine? especially without an active internet-connection?

localhost and 127.0.0.1 is treated as different host and I usually use these to test cross server scenario. One issue of AJAX is that browser usually disallow Cross Domain calls unless you specify Access-Control-Allow-Origin headers.

Upvotes: 1

Related Questions