• Post Reply Bookmark Topic Watch Topic
  • New Topic

jquery GET External Rest Service

 
G Peruana
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am invoking "GET" method for local restful services from jquery with success. But when I try an external service, I do not make it work.

<script type="text/javascript">
$.ajax({
type: "GET",
dataType: "text/xml",
url: "http://www.webservicex.net/geoipservice.asmx/GetGeoIP?IPAddress=158.42.38.1",
success: function(data){
alert("Working");
},
error:function(res){
alert("Not working ");
}
});
</script>

Does anybody see where is the error?
Thanks a lot
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you done to insure that the URL you are using is correct?

Bill
 
G Peruana
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tested it with the chrome plugin for rest client and it works.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain what you mean by "do not work". Read ItDoesntWorkIsUseless.
 
G Peruana
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means I get an error message; if I show res.statusText it just says "error".
 
G Peruana
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With chrome debugger I got the error is [...] Origin is not allowed by access-control-allow-origin. However I made it work for a different external service.
I tried to add, for this service, "Access-Control-Allow-Origin: "*"," to the Ajax code, but it does not seems to be the correct way to do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!