views:

138

answers:

1

The answer in this post http://stackoverflow.com/questions/2119680/use-jquery-to-check-if-a-url-on-another-domain-is-404-or-not shows how to use YQL in Jquery to check if URL is valid or not. However, I can't get this to work for me. The only difference I can think of is that my URL is a text file (http://mycrossdomain.com/sometext.txt) and not HTML.I think the YQL query needs to be adjusted accordingly. Any help is appreciated.

A: 

You can create a very simply data table to bring back precisely what you need with your own custom YQL queries. For example, here is a table for retrieving the headers and status for an URL.

An example table could look like: http://github.com/salathe/yql-tables/blob/master/url/status.xml

You would use it like:

use "http://github.com/salathe/yql-tables/raw/master/url/status.xml" as url.status;
select url, status from url.status where url="http://developer.yahoo.com/";

Ideally, a HTTP HEAD request would be used but AFAIK there is no way for YQL execute to do that at this time.

salathe
All I need to check is if the txt file exists. I don't need any data to be returned using YWL
If no data is returned, how will you know if it exists?
salathe
The txt file is an indication that a 'process' has been completed. I just want to check if a URL is a 404 or not.
is the txt file on the same domain as the javascript will be run from; if so you mightn't need jquery at all, this would become a plain old AJAX question
salathe
No, it's not on the same domain.