Comments on: Using YQL with JSONP https://j11y.io/snippets/using-yql-with-jsonp/ Sun, 22 Mar 2015 15:39:22 +0000 hourly 1 https://wordpress.org/?v=5.0.13 By: Chris https://j11y.io/snippets/using-yql-with-jsonp/#comment-782 Sat, 25 Jul 2009 05:44:07 +0000 https://j11y.io/?p=683#comment-782 Unfortunately, this example script doesn’t really work for yahoo search results on YQL.
(i.e. you can’t just replace the select statement).

Is there a workaround?

]]>
By: Valentino https://j11y.io/snippets/using-yql-with-jsonp/#comment-781 Thu, 09 Jul 2009 18:42:18 +0000 https://j11y.io/?p=683#comment-781 wow! someone at Yahoo listened my complains:
http://ajaxian.com/archives/pimping-json-yql-now-offers-jsonp-x

]]>
By: Mark McDonnell https://j11y.io/snippets/using-yql-with-jsonp/#comment-780 Fri, 19 Jun 2009 14:12:11 +0000 https://j11y.io/?p=683#comment-780 Hi James,

I tested your code and it works fine except that Firebug seems to bring up the following error message regarding your “src” attribute value…

not well-formed
Line 34
scriptEl.src = ‘http://query.yahooapis.com/v1/public/yql?q=’ + encodedQuery + ‘&format=json&callback=YQLQuery.’ + uid;

…not sure what you make of that, I couldn’t see anything wrong with it myself.

(there is no such error with IE so I don’t know if it’s a bug in the code or with the Firebug console itself).

Any feedback appreciated.

Thanks James.

]]>
By: Renato Albano https://j11y.io/snippets/using-yql-with-jsonp/#comment-779 Tue, 24 Mar 2009 21:00:39 +0000 https://j11y.io/?p=683#comment-779 Hi, you shoud use the jquery $.getScript function to optimize YQLQuery Class:

http://docs.jquery.com/Ajax/jQuery.getScript

Cheers!

]]>
By: Valentino https://j11y.io/snippets/using-yql-with-jsonp/#comment-778 Tue, 24 Mar 2009 20:27:19 +0000 https://j11y.io/?p=683#comment-778 I’ve made some tests and I discovered more problems:

http://www.maverick.it/m2stream/yql.php

I found YQL has these problems with HTML:

* content disappear in some cases (more below)
* ‘class’ attributes removed
* change tags order
* change some tags (‘b’ became ‘strong’)
* ambiguity between tags and attributes (think for example at style or title…)

The biggest problem I noticed is that some content may disappear.

If I try to get this HTML:

This <b>is</b> just a <strong>test</strong>

The ‘content’ of the p object contains only “just a” and not “This”.

Anyway, my function has a little bug. Now is correct:
http://snipplr.com/view/13389/yql2dom-jquery-plugin/

Thanks for the suggestions. I didn’t know Yahoo Pipes has JSON output. I’ll give it a shot. ; )

]]>
By: James https://j11y.io/snippets/using-yql-with-jsonp/#comment-777 Tue, 24 Mar 2009 08:12:27 +0000 https://j11y.io/?p=683#comment-777 @Valentino, I think the trick is to be as specific as you can with the query. So if you’re looking for all the content from ul#latest-news you could try:

select * from html where url='http://news.com' and xpath='//[@id="latest-news"]/li'

Another cool thing you can do is only select certain properties/nodes, so instead of selecting all (*) you can select all content:

select content from...

Or, for example, all HREF attributes from all anchors:

select href from... xpath='//a'

The order of the children tags returned has been correct for me so far – what lead you to that conclusion?

It may make more sense for you to use Yahoo Pipes. It requires you to make a pipe yourself but once you’ve created it you can retrieve all the HTML within any page as a string. Have a look: http://pipes.yahoo.com/pipes/pipe.edit (drag in the “fetch page” source, link it up with the output box, then save it and retrieve as JSON)

]]>
By: Valentino https://j11y.io/snippets/using-yql-with-jsonp/#comment-776 Tue, 24 Mar 2009 04:55:08 +0000 https://j11y.io/?p=683#comment-776 Unfortunatly I discovered it’s impossible.
Due to the JSON structure utilized by YQL the order of the children tags is arbitrary (and sometimes wrong).

If that’s ok for someone, here’s my function that try to convert YQL JSON to HTML: http://snipplr.com/view/13389/yql2dom-jquery-plugin/

]]>
By: Valentino https://j11y.io/snippets/using-yql-with-jsonp/#comment-775 Mon, 23 Mar 2009 23:35:17 +0000 https://j11y.io/?p=683#comment-775 Wow.. This is really amazing!
Just a newbie question: is there an easy method to rebuild the XHTML DOM structure from the JSON results? I’m trying to fetch some news from a magazine home page and inject them in a div.

]]>
By: James https://j11y.io/snippets/using-yql-with-jsonp/#comment-774 Sat, 21 Mar 2009 20:57:04 +0000 https://j11y.io/?p=683#comment-774 @Monty, Thanks for the tip about extra type-checking. To be honest, I was reluctant about integrating any input checking since I generally think it’s unnecessary in abstractions like these; I only included it for good form.

]]>
By: Monty https://j11y.io/snippets/using-yql-with-jsonp/#comment-773 Sat, 21 Mar 2009 11:34:17 +0000 https://j11y.io/?p=683#comment-773 Your use of the comma operator in yr last code section initially obfuscated to me that you were building the url parameter to use in yr getJSON call. To clarify the example and add robustness, the parameters to yr jQuery plugin could be type checked for string & function, beyond checking if not undefined.

Thanks for the useful example of using the power of JSONP and YQL to bring a remote RSS feed into the client!

]]>