views:

86

answers:

4

A long running background process creates a text file to indicate the completion of the process. From the frontend, I'd need to check every few seconds if the text file has been created or not.

I am doing this check from http://DomainA.com However the file is created in http://DomainB.com/Mytext.txt

Can someone help me write a jquery script that checks for a file across domain?

PS: Currently, I am doing a ajax postback that executes a WebMethod in ASP.NET that creates HttpWebRequest. This works functionally, but I have major performance problems. So, I need a light weight way of finding if a URL is valid or not.

Thanks

A: 

I would set up a server-side script on your own server which pings the URL (using cURL or whatever) and responds with a JSONified version of the response.

nickf
OP is doing this already (that's what `HttpWebRequest` is).
Crescent Fresh
@Crescent - i see. thanks for the info.
nickf
A: 

call it using jquery ajax, then look at the result if it is 404? This is asynchronous though, so you need to use javascript continuations if you are in a workflow

Eugene Ramirez
Cross-domain *AJAX* requests are blocked by browsers.
Delan Azabani
You can not do cross-domain requests via XHR.
friedo
A: 

Do not fire HttpWebRequest at the moment the jQuery script requests it. Run HttpWebRequest independently at same intervals in some background thread which in turn sets some shared boolean toggle. Finally let the code which should respond to jQuery requests return the state of this toggle (thus without firing the HttpWebRequest itself).

BalusC
If the performance bottleneck is due to HttpWebRequest, I am not sure how triggering it separately would make any difference. Let me know if I have'nt understood your answer correctly.
So that the jQuery doesn't have to wait until `HttpWebRequest` finishes. It should just grab the "last known" result.
BalusC
Do you think that JQuery waiting for the HttpWebRequest is the one that's causing the exceptions? In the event viewer, I see timeout exceptions.
No, it's the `HttpWebRequest` itself which takes so long. Just fire it in intervals in a background thread and let it set a commonly accessible variable which jQuery just have to request at its own intervals.
BalusC
A: 

I ended up using YQL with JQuery that lets me do cross domain requests.