JanardhanReddy
JanardhanReddy

Reputation: 65

how can i get data from a remote website in JavaScript?

I want to get the data from http://whatismyip.com/automation/n09230945.asp using JavaScript. How can I do this?

I can get the data from ASP.NET by using WebClient class but how can we get data using JavaScript?

Upvotes: 1

Views: 800

Answers (3)

Christopher Scott
Christopher Scott

Reputation: 3126

Use YQL - http://developer.yahoo.com/yql/guide/yql-code-examples.html#yql_html_scraper

It essentially acts as a proxy to grab page data for you through their service. You can interact with it solely with JavaScript.

Upvotes: 0

sp.
sp.

Reputation: 1326

The way to get around the same origin policy is to write a script in ASP on your own server that gets the data, and then get that script through AJAX in your page.

Upvotes: 0

Max Shawabkeh
Max Shawabkeh

Reputation: 38603

You will need to use AJAX. However, unless the service provides a JSONP interface, AJAX is limited to getting pages from the same domain as the page it runs on. See: Same origin policy.

Upvotes: 4

Related Questions