padolsey-archive / jquery.fn

A collection of jQuery plugins
http://james.padolsey.com
The Unlicense
1.1k stars 723 forks source link

Results always come back empty? #11

Open btkelly opened 12 years ago

btkelly commented 12 years ago

I just dropped in this plugin and the code seems to be running as it should but when it tries to call my success function it crashes on "Uncaught TypeError: Cannot call method 'replace' of undefined". This is caused because the data.results[0] does not exist. Why would this be happening, am I missing something?

Here is the yql script section "jQuery16408109300213400275_1320019527725({"query":{"count":"0","created":"2011-10-31T00:10:05Z","lang":"en-US"},"results":[]});"

Any help would be great. Thanks

Bryan

alexbarber commented 12 years ago

I'm getting the same issue: "Cannot call method 'replace' of undefined" - did Yahoo change how things work on their end again?

padolsey commented 12 years ago

May I ask what pages are you requesting?

This doesn't occur for me, on e.g. $.get('http://google.com', function(){...}).

If this is occurring I would guess that it's because YQL wasn't able to get any results. I can only help if you give me more details about the specifics of your issue :)

alexbarber commented 12 years ago

I've used it with success previously on the blog on http://www.arthurmeyerson.com

The main site runs in django CMS. On the blog, which runs on WordPress, I make a call to the main site to scrape the nav with dropdowns at the top of the page, and then paint that nav in the blog. I do this since the main site dropdowns change from time to time as photo categories can change.

Now that call returns nothing, so I wondered if something shifted in YQL.

Alex // ab // alexbarber.com

On Sat, Nov 12, 2011 at 4:06 AM, James Padolsey < reply@reply.github.com

wrote:

May I ask what pages are you requesting?

This doesn't occur for me, on e.g. $.get('http://google.com', function(){...}).

If this is occurring I would guess that it's because YQL wasn't able to get any results. I can only help if you give me more details about the specifics of your issue :)


Reply to this email directly or view it on GitHub:

https://github.com/jamespadolsey/jQuery-Plugins/issues/11#issuecomment-2716868

libricoleur commented 12 years ago

Getting the same issue while it used to work just fine. I can read from my web server's logs that YQL gets the page:

217.146.191.19 kar.ch[]()ezmandre.net - [13/Nov/2011:00:51:39 +0100] "GET /pub/whois[]()onchat.pih HTTP/1.0" 200 588 "-" "Mozilla/5.0 (compatible; Yahoo Pipes 2.0; +http://developer.yahoo.com/yql/provider) Gecko/20090729 Firefox/3.5.2"

But data.results[0] is undefined. Tried to switch between jQuery versions with no success, so I guess it's a YQL issue. BTW I use it like this:

$('#mycontainer').load('http[]()://kar.ch[]()ezmandre.net/pub/whois[]()onchat.pih #maindiv');

padolsey commented 12 years ago

Please have a look at http://developer.yahoo.com/yql/console

Here you can type in your query -- which is essentially what this plugin is doing.

i.e.

SELECT * FROM html WHERE url = "http://YOUR-URL.COM"

YQL will provide you with the results, or errors if it encountered any.

libricoleur commented 12 years ago

Thank you for your help! I didn't know about this tool. I finally got it to work again. The YQL console's JSON output returned with a null "results" field. I eventually found out it was because of an encoding conflict. The HTTP header said the encoding was ascii while the page had <?xml version="1.0" encoding="iso8859-1"?> as first line. Removing that line made both the console and the plugin get the page. I don't really like it since I have different encodings on different pages and I think some scripts will break if I change the coding server-side. I'll give it a try. Anyway, I wonder if that's a bug or a wanted new YQL behavior? Thank you very much once again!

EDIT: I found how to set the encoding field in the HTTP header from my script. Now everything work just fine!