This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

jquery GET External Rest Service

 
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
 
Author and all-around good cowpoke
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.
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
This is my favorite show. And this is my favorite tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic