The same origin policy in browsers can sometimes be a hindrance and headache. All you want to do is fetch some html from some url, scrape it, do magical stuff with it for your all-too-shiny new mash-up, but this damn cross-domain restrictions! Well, that's where JSONP comes in.
Here is a github repository for a simple JSONP url source provider : http://fetch-url.appspot.com
Have a look at sample code to get a flavor of it.
Enter url of a page:
Here is a github repository for a simple JSONP url source provider : http://fetch-url.appspot.com
Have a look at sample code to get a flavor of it.
function myCallback (json) { var page_source = json.source; // do stuff with page source here. // for example, counting links. alert ("The page has " + $(page_source).find('a').length + " links."); } var url = "http://google.com"; $.ajax({ url: "http://fetch-url.appspot.com" + "?url=" + url + "&funcname=myCallback", dataType: "jsonp" });
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.