How to send data to remote server using Javascript

前端 未结 3 1365
栀梦
栀梦 2020-11-29 08:43

I need to send data to a remote server using javascript. How do I do this?

Background info: There\'s a webpage from which I extract some information

3条回答
  •  失恋的感觉
    2020-11-29 09:34

    • submit a form using POST. That is working on all browsers cross domains. Have the server process the post. the form can be submitted to a hidden frame if you want to simulate AJAX
    • Use Cross Domain Resource Sharing (MDC) (IE XDR)
    • use a web bug (create an image, set the source to the url you want - smallish GET requests only)

      var img = new Image();
      img.src="http://www.otherserver.com/getxml?xml="+encodeURIComponent(yourXML); (Oops, I see Lebedev did more or less the same in his update)

    • use a proxy, i.e. have your server talk to the other server for you

提交回复
热议问题