1

This is a more can I, then a how to question. When I send data to a servlet, and they are both on the same domain, I use :

$.post('action.do', {arrayData:myArray, mode:"insert"});

or something similar. If, for example, I have html running within an android app on my device and I have a server in the cloud, can I perform something such as :

$.post('http://www.example.com/action.do', {arrayData:myArray, mode:"insert"});

Where example.com is the domain I have the server on, is this possible? Thanks

jmj
  • 237,923
  • 42
  • 401
  • 438
user1501171
  • 210
  • 1
  • 3
  • 17

2 Answers2

0

Yes, you can. You just cannot post to a server sitting on another domain, it's prevented by Ajax cross-domain policy of many browsers.

Beat Richartz
  • 9,474
  • 1
  • 33
  • 50
0

Yes it is possible

$.ajax({
  type: "POST",
  url: "http://www.example.com/action.do",
  data: { param1: "cal1" , param2: "val2" }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );
});

See Also

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438