javascript - Is there any way to use the JQuery GetJSON method to get HTML from an external page? -


so let's you're trying jquery ajax request, like:

$.ajax({     ...     url: http://other-website.com     ... }) 

i understand because of same-origin principle, request fail because url external domain.

however i've heard getjson() not obey principle , can send asynchronous requests external servers using jsonp , appended url.

my question is: possible use getjson() retrieve html external name single string within json object? if doesn't default, there way can force / trick doing so?

yes, can request html remote location, must use proxy so. 1 publicly available proxy yql.

http://jsfiddle.net/bkjwu/

var query = 'select * html url="http://mattgemmell.com/2008/12/08/what-have-you-tried/" , xpath="//h1" , class="entry-title"'; var url = "http://query.yahooapis.com/v1/public/yql?q=" + query + "&format=json&callback=??";   $.getjson(url,function(data){     alert(data.query.results.h1.content); }) 

you of course build own on server returns plain html rather json.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -